mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-04 08:47:23 +08:00
Refactor money value formatting
Do not duplicate code and send string value for JPY
This commit is contained in:
parent
67cdf9be8e
commit
82adf1933f
5 changed files with 84 additions and 18 deletions
|
@ -22,9 +22,7 @@ class AmountTest extends TestCase
|
|||
|
||||
public function testBreakdownIsNull()
|
||||
{
|
||||
$money = Mockery::mock(Money::class);
|
||||
$money->shouldReceive('currency_code')->andReturn('currencyCode');
|
||||
$money->shouldReceive('value')->andReturn(1.10);
|
||||
$money = new Money(1.10, 'currencyCode');
|
||||
$testee = new Amount($money);
|
||||
|
||||
$this->assertNull($testee->breakdown());
|
||||
|
@ -38,9 +36,7 @@ class AmountTest extends TestCase
|
|||
|
||||
public function testBreakdown()
|
||||
{
|
||||
$money = Mockery::mock(Money::class);
|
||||
$money->shouldReceive('currency_code')->andReturn('currencyCode');
|
||||
$money->shouldReceive('value')->andReturn(1.10);
|
||||
$money = new Money(1.10, 'currencyCode');
|
||||
$breakdown = Mockery::mock(AmountBreakdown::class);
|
||||
$breakdown->shouldReceive('to_array')->andReturn([1]);
|
||||
$testee = new Amount($money, $breakdown);
|
||||
|
|
|
@ -334,6 +334,25 @@ class PurchaseUnitTest extends TestCase
|
|||
],
|
||||
]),
|
||||
];
|
||||
|
||||
yield 'no decimals currency' => [
|
||||
[
|
||||
'currency' => 'JPY',
|
||||
'items' => [
|
||||
['price' => 18.0, 'quantity' => 2],
|
||||
],
|
||||
'shipping' => ['total' => 5.0],
|
||||
'billing' => ['city' => 'city2'],
|
||||
],
|
||||
self::adaptAmountFormat([
|
||||
'value' => 66,
|
||||
'breakdown' => [
|
||||
'item_total' => 36,
|
||||
'tax_total' => 25, // 24.60
|
||||
'shipping' => 5,
|
||||
],
|
||||
], 'JPY'),
|
||||
];
|
||||
}
|
||||
|
||||
public function cartData() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue