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

85 lines
1.9 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
class PaymentsTest extends TestCase
{
2020-09-28 11:47:24 +03:00
public function testAuthorizations()
{
$authorization = \Mockery::mock(Authorization::class);
$authorizations = [$authorization];
2020-08-31 13:38:54 +03:00
2020-09-28 11:47:24 +03:00
$testee = new Payments($authorizations, []);
2020-08-31 13:38:54 +03:00
2020-09-28 11:47:24 +03:00
$this->assertEquals($authorizations, $testee->authorizations());
}
public function testCaptures()
{
$capture = \Mockery::mock(Capture::class);
$captures = [$capture];
$testee = new Payments([], $captures);
$this->assertEquals($captures, $testee->captures());
}
2020-08-31 13:38:54 +03:00
public function testToArray()
{
$authorization = \Mockery::mock(Authorization::class);
2020-09-01 09:47:36 +03:00
$authorization->shouldReceive('to_array')->andReturn(
2020-08-31 13:38:54 +03:00
[
'id' => 'foo',
'status' => 'CREATED',
]
);
2020-09-28 11:47:24 +03:00
$capture = \Mockery::mock(Capture::class);
$capture->shouldReceive('to_array')->andReturn(
[
'id' => 'capture',
'status' => 'CREATED',
]
);
2023-08-04 14:18:27 +01:00
$refund = \Mockery::mock(Refund::class);
$refund->shouldReceive('to_array')->andReturn(
[
'id' => 'refund',
'status' => 'CREATED',
]
);
2020-08-31 13:38:54 +03:00
$authorizations = [$authorization];
2023-08-04 14:18:27 +01:00
$captures = [$capture];
$refunds = [$refund];
2020-08-31 13:38:54 +03:00
2023-08-04 14:18:27 +01:00
$testee = new Payments($authorizations, $captures, $refunds);
2020-08-31 13:38:54 +03:00
$this->assertEquals(
[
'authorizations' => [
[
'id' => 'foo',
'status' => 'CREATED',
],
],
2020-09-28 11:47:24 +03:00
'captures' => [
[
'id' => 'capture',
'status' => 'CREATED',
],
],
2023-08-04 14:18:27 +01:00
'refunds' => [
[
'id' => 'refund',
'status' => 'CREATED',
],
],
2020-08-31 13:38:54 +03:00
],
2020-09-01 09:47:36 +03:00
$testee->to_array()
2020-08-31 13:38:54 +03:00
);
}
}