Skip to content

Commit

Permalink
[ECP-9247] Update unit test for merchant reference check
Browse files Browse the repository at this point in the history
  • Loading branch information
sushmita committed Jun 19, 2024
1 parent 5c2be93 commit 89c6d02
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions Test/Unit/Helper/PaymentResponseHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ protected function setUp(): void
$this->orderMock->method('getQuoteId')->willReturn(1);
$this->orderMock->method('getPayment')->willReturn($this->paymentMock);
$this->orderMock->method('getStatus')->willReturn('pending');
$this->orderMock->method('getIncrementId')->willReturn('00123456');

$this->orderHelperMock->method('setStatusOrderCreation')->willReturn( $this->orderMock);

Expand Down Expand Up @@ -117,7 +118,7 @@ public function testFormatPaymentResponseForFinalResultCodes($resultCode)
$this->assertEquals($expectedResult, $result);
}

private static function dataSourceForFormatPaymentResponseActionRequredPayments(): array
private static function dataSourceForFormatPaymentResponseActionRequiredPayments(): array
{
return [
['resultCode' => PaymentResponseHandler::REDIRECT_SHOPPER, 'action' => ['type' => 'qrCode']],
Expand All @@ -131,7 +132,7 @@ private static function dataSourceForFormatPaymentResponseActionRequredPayments(
* @param $resultCode
* @param $action
* @return void
* @dataProvider dataSourceForFormatPaymentResponseActionRequredPayments
* @dataProvider dataSourceForFormatPaymentResponseActionRequiredPayments
*/
public function testFormatPaymentResponseForActionRequiredPayments($resultCode, $action)
{
Expand Down Expand Up @@ -239,7 +240,8 @@ public function testHandlePaymentsDetailsResponseAuthorised()
'details' => [
'someData' => 'someValue'
],
'donationToken' => 'XYZ123456789'
'donationToken' => 'XYZ123456789',
'merchantReference' => '00123456'
];

$this->quoteHelperMock->method('disableQuote')->willThrowException(new Exception());
Expand Down Expand Up @@ -281,7 +283,8 @@ public function testHandlePaymentsDetailsResponsePending($paymentMethodCode)
'pspReference' => 'ABC123456789',
'paymentMethod' => [
'brand' => $paymentMethodCode
]
],
'merchantReference' => '00123456'
];

$result = $this->paymentResponseHandler->handlePaymentsDetailsResponse(
Expand Down Expand Up @@ -314,7 +317,8 @@ public function testHandlePaymentsDetailsResponseReceived($paymentMethodCode, $e
'pspReference' => 'ABC123456789',
'paymentMethod' => [
'brand' => $paymentMethodCode
]
],
'merchantReference' => '00123456'
];

$result = $this->paymentResponseHandler->handlePaymentsDetailsResponse(
Expand Down Expand Up @@ -350,6 +354,7 @@ public function testHandlePaymentsDetailsResponseActionRequired($resultCode)
'paymentMethod' => [
'brand' => 'ideal'
],
'merchantReference' => '00123456',
'action' => [
'actionData' => 'actionValue'
]
Expand Down Expand Up @@ -388,6 +393,7 @@ public function testHandlePaymentsDetailsResponseCancelOrRefused($resultCode)
'paymentMethod' => [
'brand' => 'ideal'
],
'merchantReference' => '00123456',
'action' => [
'actionData' => 'actionValue'
]
Expand Down Expand Up @@ -431,4 +437,22 @@ public function testHandlePaymentsDetailsEmptyResponse()

$this->assertFalse($result);
}

public function testHandlePaymentsDetailsResponseInvalidMerchantReference(){
$paymentsDetailsResponse = [
'resultCode' => PaymentResponseHandler::AUTHORISED,
'pspReference' => 'ABC123456789',
'paymentMethod' => [
'brand' => 'ideal'
],
'merchantReference' => '00777777'
];

$result = $this->paymentResponseHandler->handlePaymentsDetailsResponse(
$paymentsDetailsResponse,
$this->orderMock
);

$this->assertFalse($result);
}
}

0 comments on commit 89c6d02

Please sign in to comment.