mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Test for AuthorizationFactory
This commit is contained in:
parent
5427f4ae83
commit
c72e4aa505
1 changed files with 53 additions and 0 deletions
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Inpsyde\PayPalCommerce\ApiClient\Factory;
|
||||
|
||||
use Inpsyde\PayPalCommerce\ApiClient\Entity\Authorization;
|
||||
use Inpsyde\PayPalCommerce\ApiClient\Entity\AuthorizationStatus;
|
||||
use Inpsyde\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||
use Inpsyde\PayPalCommerce\ApiClient\TestCase;
|
||||
|
||||
class AuthorizationFactoryTest extends TestCase
|
||||
{
|
||||
public function testFromPayPalRequestDefault()
|
||||
{
|
||||
$response = (object)[
|
||||
'id' => 'foo',
|
||||
'status' => 'CAPTURED',
|
||||
];
|
||||
|
||||
$testee = new AuthorizationFactory();
|
||||
$result = $testee->fromPayPalRequest($response);
|
||||
|
||||
$this->assertInstanceOf(Authorization::class, $result);
|
||||
|
||||
$this->assertEquals('foo', $result->id());
|
||||
$this->assertInstanceOf(AuthorizationStatus::class, $result->status());
|
||||
|
||||
$this->assertEquals('CAPTURED', $result->status()->name());
|
||||
}
|
||||
|
||||
public function testReturnExceptionIdIsMissing()
|
||||
{
|
||||
$this->expectException(RuntimeException::class);
|
||||
$response = (object)[
|
||||
'status' => 'CAPTURED',
|
||||
];
|
||||
|
||||
$testee = new AuthorizationFactory();
|
||||
$testee->fromPayPalRequest($response);
|
||||
}
|
||||
|
||||
public function testReturnExceptionStatusIsMissing()
|
||||
{
|
||||
$this->expectException(RuntimeException::class);
|
||||
$response = (object)[
|
||||
'id' => 'foo',
|
||||
];
|
||||
|
||||
$testee = new AuthorizationFactory();
|
||||
$testee->fromPayPalRequest($response);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue