diff --git a/modules.local/ppcp-api-client/tests/PHPUnit/Factory/AuthorizationFactoryTest.php b/modules.local/ppcp-api-client/tests/PHPUnit/Factory/AuthorizationFactoryTest.php new file mode 100644 index 000000000..4544f35ce --- /dev/null +++ b/modules.local/ppcp-api-client/tests/PHPUnit/Factory/AuthorizationFactoryTest.php @@ -0,0 +1,53 @@ + '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); + } +}