mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-01 07:02:48 +08:00
Use str value when checking mismatch
Otherwise the check may fail depending on the rounding used when creating the Money objects
This commit is contained in:
parent
82adf1933f
commit
2ca64739db
3 changed files with 41 additions and 24 deletions
|
@ -68,8 +68,6 @@ class PurchaseUnitTest extends TestCase
|
|||
$pu = $this->puFactory->from_wc_order($wcOrder);
|
||||
$puData = $pu->to_array();
|
||||
|
||||
self::assertTrue(isset($puData['amount']['breakdown']));
|
||||
|
||||
self::assertEquals($expectedAmount, $puData['amount']);
|
||||
}
|
||||
|
||||
|
@ -83,8 +81,6 @@ class PurchaseUnitTest extends TestCase
|
|||
$pu = $this->puFactory->from_wc_cart($this->cart);
|
||||
$puData = $pu->to_array();
|
||||
|
||||
self::assertTrue(isset($puData['amount']['breakdown']));
|
||||
|
||||
self::assertEquals($expectedAmount, $puData['amount']);
|
||||
}
|
||||
|
||||
|
@ -353,6 +349,18 @@ class PurchaseUnitTest extends TestCase
|
|||
],
|
||||
], 'JPY'),
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
'items' => [
|
||||
['price' => 5.345, 'quantity' => 2],
|
||||
],
|
||||
'billing' => ['city' => 'city0'],
|
||||
],
|
||||
self::adaptAmountFormat([
|
||||
'value' => 10.69,
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
public function cartData() {
|
||||
|
@ -409,6 +417,18 @@ class PurchaseUnitTest extends TestCase
|
|||
],
|
||||
], get_woocommerce_currency()),
|
||||
];
|
||||
|
||||
yield [
|
||||
[
|
||||
'products' => [
|
||||
['price' => 5.345, 'quantity' => 2],
|
||||
],
|
||||
'billing' => ['city' => 'city0'],
|
||||
],
|
||||
self::adaptAmountFormat([
|
||||
'value' => 10.69,
|
||||
], get_woocommerce_currency()),
|
||||
];
|
||||
}
|
||||
|
||||
private static function adaptAmountFormat(array $data, string $currency = null): array {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue