Refactor PurchaseUnitSanitizer to subtract 0.01 instead of rounding down

Refactor PurchaseUnitSanitizer to use singleton pattern
This commit is contained in:
Pedro Silva 2023-08-09 11:48:49 +01:00
parent dea55e24c4
commit bb3b8553b9
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
8 changed files with 70 additions and 61 deletions

View file

@ -662,11 +662,11 @@ class PurchaseUnitTest extends TestCase
'insurance' => null,
],
],
'with_rounding_down_only_first_item' => [
'message' => 'Extra line should be added with price 0.01 and lines amount 10.00 and 5.00.',
'with_two_rounding_down' => [
'message' => 'Extra line should be added with price 0.03 and lines amount 10.00 and 4.99.',
'expected' => [
'item_value' => [10.00, 5.00],
'extra_line_value' => 0.01
'item_value' => [10.00, 4.99],
'extra_line_value' => 0.03
],
'items' => [
[
@ -693,11 +693,11 @@ class PurchaseUnitTest extends TestCase
'insurance' => null,
],
],
'with_multiple_roundings_down' => [
'with_many_roundings_down' => [
'message' => 'Extra line should be added with price 0.01 and lines amount 10.00, 5.00 and 6.66.',
'expected' => [
'item_value' => [10.00, 5.00, 6.66],
'extra_line_value' => 0.01
'item_value' => [10.00, 4.99, 6.66],
'extra_line_value' => 0.02
],
'items' => [
[