woocommerce-paypal-payments/tests/PHPUnit/ApiClient/Entity/AmountTest.php

54 lines
1.4 KiB
PHP
Raw Normal View History

2020-08-31 13:38:54 +03:00
<?php
declare(strict_types=1);
2020-09-14 07:51:45 +03:00
namespace WooCommerce\PayPalCommerce\ApiClient\Entity;
2020-08-31 13:38:54 +03:00
2022-02-09 16:28:27 +02:00
use WooCommerce\PayPalCommerce\TestCase;
2020-08-31 13:38:54 +03:00
use Mockery;
class AmountTest extends TestCase
{
public function test()
{
$money = Mockery::mock(Money::class);
2020-09-01 09:47:36 +03:00
$money->shouldReceive('currency_code')->andReturn('currencyCode');
2020-08-31 13:38:54 +03:00
$money->shouldReceive('value')->andReturn(1.10);
$testee = new Amount($money);
2020-09-01 09:47:36 +03:00
$this->assertEquals('currencyCode', $testee->currency_code());
2020-08-31 13:38:54 +03:00
$this->assertEquals(1.10, $testee->value());
}
public function testBreakdownIsNull()
{
$money = new Money(1.10, 'currencyCode');
2020-08-31 13:38:54 +03:00
$testee = new Amount($money);
$this->assertNull($testee->breakdown());
$expectedArray = [
'currency_code' => 'currencyCode',
'value' => 1.10,
];
2020-09-01 09:47:36 +03:00
$this->assertEquals($expectedArray, $testee->to_array());
2020-08-31 13:38:54 +03:00
}
public function testBreakdown()
{
$money = new Money(1.10, 'currencyCode');
2020-08-31 13:38:54 +03:00
$breakdown = Mockery::mock(AmountBreakdown::class);
2020-09-01 09:47:36 +03:00
$breakdown->shouldReceive('to_array')->andReturn([1]);
2020-08-31 13:38:54 +03:00
$testee = new Amount($money, $breakdown);
$this->assertEquals($breakdown, $testee->breakdown());
$expectedArray = [
'currency_code' => 'currencyCode',
'value' => 1.10,
'breakdown' => [1],
];
2020-09-01 09:47:36 +03:00
$this->assertEquals($expectedArray, $testee->to_array());
2020-08-31 13:38:54 +03:00
}
}