diff --git a/tests/Functional/AkbankPosTest.php b/tests/Functional/AkbankPosTest.php index 2fd8bbe7..0d53f7c8 100644 --- a/tests/Functional/AkbankPosTest.php +++ b/tests/Functional/AkbankPosTest.php @@ -231,6 +231,33 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro return $lastResponse; } + /** + * @depends testNonSecurePostPaymentSuccess + */ + public function testRefundSuccess(array $lastResponse): array + { + $refundOrder = $this->createRefundOrder(\get_class($this->pos), $lastResponse); + + $eventIsThrown = false; + $this->eventDispatcher->addListener( + RequestDataPreparedEvent::class, + function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThrown): void { + $eventIsThrown = true; + $this->assertSame(PosInterface::TX_TYPE_REFUND, $requestDataPreparedEvent->getTxType()); + $this->assertCount(7, $requestDataPreparedEvent->getRequestData()); + }); + + $this->pos->refund($refundOrder); + + $response = $this->pos->getResponse(); + $this->assertTrue($this->pos->isSuccess(), $response['error_message'] ?? ''); + $this->assertIsArray($response); + $this->assertNotEmpty($response); + $this->assertTrue($eventIsThrown); + + return $lastResponse; + } + public function testNonSecurePaymentRecurringSuccess(): array { $order = $this->createPaymentOrder( @@ -403,6 +430,7 @@ function (RequestDataPreparedEvent $requestDataPreparedEvent) use (&$eventIsThro $this->recurringPos->history($historyOrder); $response = $this->recurringPos->getResponse(); + $this->assertTrue($this->recurringPos->isSuccess()); $this->assertIsArray($response); $this->assertTrue($eventIsThrown); $this->assertNotEmpty($response['transactions']);