Skip to content

Commit

Permalink
tests - added PayFor e2e refund test
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed Jan 21, 2024
1 parent e9cc862 commit 7867a36
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/Functional/PayForPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function (RequestDataPreparedEvent $event) use (&$eventIsThrown) {
}

/**
* @depends testNonSecurePostPaymentSuccess
* @depends testNonSecurePaymentSuccess
* @depends testStatusSuccess
*/
public function testCancelSuccess(array $lastResponse): array
Expand Down Expand Up @@ -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;
}
}

0 comments on commit 7867a36

Please sign in to comment.