Skip to content

Commit

Permalink
tests - added refund test to AkbankPos functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed May 29, 2024
1 parent 71b4b36 commit bb6df2d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/Functional/AkbankPosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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']);
Expand Down

0 comments on commit bb6df2d

Please sign in to comment.