|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Omnipay\IcepayPayments\Message; |
| 4 | + |
| 5 | +use Omnipay\IcepayPayments\AbstractTestCase; |
| 6 | + |
| 7 | +/** |
| 8 | + * Class RefundResponseTest. |
| 9 | + */ |
| 10 | +class RefundResponseTest extends AbstractTestCase |
| 11 | +{ |
| 12 | + /** |
| 13 | + * @var TransactionStatusRequest |
| 14 | + */ |
| 15 | + private $request; |
| 16 | + |
| 17 | + /** |
| 18 | + * Creates a new TransactionStatusRequest instance. |
| 19 | + */ |
| 20 | + protected function setUp(): void |
| 21 | + { |
| 22 | + parent::setUp(); |
| 23 | + |
| 24 | + $this->request = new RefundRequest($this->httpClient, $this->httpRequest); |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Tests if TransactionStatusResponse::isSuccessful will return true with the given json response. |
| 29 | + */ |
| 30 | + public function testResponseReturnsSuccessful(): void |
| 31 | + { |
| 32 | + $responseJsonBody = file_get_contents(__DIR__.'/../Mocks/RefundSuccess.json'); |
| 33 | + $response = new RefundResponse($this->request, json_decode($responseJsonBody, true)); |
| 34 | + |
| 35 | + $expectedResponseBody = [ |
| 36 | + 'RefundId' => '7c9cb2f4-83ce-4b10-8d5c-de230181224f', |
| 37 | + 'RefundStatusCode' => AbstractResponse::RESPONSE_STATUS_COMPLETED, |
| 38 | + 'RefundStatusDetails' => '', |
| 39 | + 'AcquirerRefundId' => '', |
| 40 | + ]; |
| 41 | + |
| 42 | + $this->assertTrue($response->isSuccessful()); |
| 43 | + $this->assertSame($expectedResponseBody, $response->getData()); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * Tests if TransactionStatusResponse::isSuccessful will return false from the json response. |
| 48 | + */ |
| 49 | + public function testIfResponseReturnNotSuccessful(): void |
| 50 | + { |
| 51 | + $responseJsonBody = file_get_contents(__DIR__.'/../Mocks/RefundFail.json'); |
| 52 | + $response = new RefundResponse($this->request, json_decode($responseJsonBody, true)); |
| 53 | + |
| 54 | + $this->assertFalse($response->isSuccessful()); |
| 55 | + } |
| 56 | +} |
0 commit comments