diff --git a/tests/Functional/PayForPosTest.php b/tests/Functional/PayForPosTest.php index 3f21a1cc..c07f33af 100644 --- a/tests/Functional/PayForPosTest.php +++ b/tests/Functional/PayForPosTest.php @@ -117,7 +117,7 @@ function (RequestDataPreparedEvent $event) use (&$eventIsThrown) { } /** - * @depends testNonSecurePostPaymentSuccess + * @depends testNonSecurePaymentSuccess * @depends testStatusSuccess */ public function testCancelSuccess(array $lastResponse): array @@ -256,4 +256,32 @@ function (Before3DFormHashCalculatedEvent $event) use (&$eventIsThrown) { $this->assertArrayHasKey('test_input', $formData['inputs']); $this->assertTrue($eventIsThrown); } + + /** + * @depends testNonSecurePostPaymentSuccess + */ + public function testRefundFail(array $lastResponse): array + { + $refundOrder = $this->createRefundOrder(\get_class($this->pos), $lastResponse); + + $eventIsThrown = false; + $this->eventDispatcher->addListener( + RequestDataPreparedEvent::class, + function (RequestDataPreparedEvent $event) use (&$eventIsThrown) { + $eventIsThrown = true; + $this->assertSame(PosInterface::TX_TYPE_REFUND, $event->getTxType()); + $this->assertCount(10, $event->getRequestData()); + }); + + $this->pos->refund($refundOrder); + + $this->assertFalse($this->pos->isSuccess()); + $response = $this->pos->getResponse(); + $this->assertIsArray($response); + $this->assertNotEmpty($response); + $this->assertSame('V014', $response['proc_return_code']); + $this->assertTrue($eventIsThrown); + + return $lastResponse; + } }