From 7929bdd3b2c738dad1264097e815c70c1d328c14 Mon Sep 17 00:00:00 2001 From: mustapayev Date: Sun, 27 Oct 2024 11:19:03 +0100 Subject: [PATCH] fix response data is missing in some transactions --- .../GarantiPosResponseDataMapper.php | 1 + .../InterPosResponseDataMapper.php | 1 + .../PayForPosResponseDataMapper.php | 1 + .../AkbankPosResponseDataMapperTest.php | 30 +++++++++++- .../EstPosResponseDataMapperTest.php | 43 ++++++++++++++++ .../GarantiPosResponseDataMapperTest.php | 39 +++++++++++++++ .../InterPosResponseDataMapperTest.php | 38 +++++++++++++- .../KuveytPosResponseDataMapperTest.php | 14 ++++++ .../PayFlexCPV4PosResponseDataMapperTest.php | 4 ++ .../PayFlexV4PosResponseDataMapperTest.php | 30 ++++++++++++ .../PayForPosResponseDataMapperTest.php | 49 ++++++++++++++++++- .../PosNetResponseDataMapperTest.php | 20 ++++++++ .../PosNetV1PosResponseDataMapperTest.php | 33 ++++++++++++- .../ToslaPosResponseDataMapperTest.php | 41 ++++++++++++++-- .../VakifKatilimPosResponseDataMapperTest.php | 41 ++++++++++++++++ 15 files changed, 375 insertions(+), 10 deletions(-) diff --git a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php index 556873a5..c0b5491e 100644 --- a/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapper.php @@ -169,6 +169,7 @@ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txTyp $paymentModel ); $defaultPaymentResponse['status'] = $paymentStatus; + $defaultPaymentResponse['all'] = $raw3DAuthResponseData; if (self::TX_APPROVED === $threeDAuthStatus) { $threeDAuthResult['auth_code'] = $raw3DAuthResponseData['authcode']; diff --git a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php index 0f4d0282..4e34446a 100644 --- a/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/InterPosResponseDataMapper.php @@ -52,6 +52,7 @@ public function mapPaymentResponse(array $rawPaymentResponseData, string $txType $result['error_message'] = $rawPaymentResponseData['ErrorMessage']; $result['currency'] = $order['currency']; $result['amount'] = $order['amount']; + $result['all'] = $rawPaymentResponseData; if (self::TX_APPROVED === $status) { $result['transaction_time'] = new \DateTimeImmutable($rawPaymentResponseData['TRXDATE'] ?? null); diff --git a/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php b/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php index c008253b..b9dde0cf 100644 --- a/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php +++ b/src/DataMapper/ResponseDataMapper/PayForPosResponseDataMapper.php @@ -150,6 +150,7 @@ public function map3DPayResponseData(array $raw3DAuthResponseData, string $txTyp 'status_detail' => $this->getStatusDetail($procReturnCode), 'error_code' => (self::TX_APPROVED !== $status) ? $procReturnCode : null, 'error_message' => (self::TX_APPROVED !== $status) ? $raw3DAuthResponseData['ErrMsg'] : null, + 'all' => $raw3DAuthResponseData, ]; $commonThreeDResponseData = $this->map3DCommonResponseData($raw3DAuthResponseData); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapperTest.php index f0f22df9..6be65b97 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/AkbankPosResponseDataMapperTest.php @@ -79,7 +79,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -103,8 +108,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD } unset($actualData['transaction_time'], $expectedData['transaction_time']); - unset($actualData['all']); - unset($actualData['3d_all']); + + $this->assertArrayHasKey('all', $actualData); + if ([] !== $responseData) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } + $this->assertArrayHasKey('3d_all', $actualData); + $this->assertIsArray($actualData['3d_all']); + $this->assertNotEmpty($actualData['3d_all']); + unset($actualData['all'], $actualData['3d_all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -123,10 +137,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $re } unset($actualData['transaction_time'], $expectedData['transaction_time']); + $this->assertArrayHasKey('all', $actualData); $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -145,10 +161,12 @@ public function testMap3DHostResponseData(array $order, string $txType, array $r } unset($actualData['transaction_time'], $expectedData['transaction_time']); + $this->assertArrayHasKey('all', $actualData); $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -160,10 +178,12 @@ public function testMap3DHostResponseData(array $order, string $txType, array $r public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + $this->assertArrayHasKey('all', $actualData); $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($actualData); \ksort($expectedData); $this->assertSame($expectedData, $actualData); @@ -175,10 +195,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData): public function testMapCancelResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($responseData); + $this->assertArrayHasKey('all', $actualData); $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($actualData); \ksort($expectedData); $this->assertSame($expectedData, $actualData); @@ -217,7 +239,11 @@ public function testMapOrderHistoryResponse(array $responseData, array $expected } } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php index e34cab14..31be4aa0 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/EstPosResponseDataMapperTest.php @@ -82,7 +82,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp $actualData = $this->responseDataMapper->mapPaymentResponse($responseData, $txType, $order); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -101,7 +106,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD ); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + if ([] !== $paymentResponse) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } + $this->assertArrayHasKey('3d_all', $actualData); + $this->assertIsArray($actualData['3d_all']); + $this->assertNotEmpty($actualData['3d_all']); unset($actualData['all'], $actualData['3d_all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -115,7 +130,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $re $actualData = $this->responseDataMapper->map3DPayResponseData($responseData, $txType, $order); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -134,7 +154,12 @@ public function testMap3DHostResponseData(array $order, string $txType, array $r } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -168,7 +193,11 @@ public function testMapStatusResponse(array $responseData, array $expectedData): unset($actualData['refund_time'], $expectedData['refund_time']); } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); @@ -181,7 +210,12 @@ public function testMapStatusResponse(array $responseData, array $expectedData): public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -191,7 +225,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData): public function testMapCancelResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -223,7 +262,11 @@ public function testMapOrderHistoryResponse(array $responseData, array $expected $this->assertCount($actualData['trans_count'], $actualData['transactions']); } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php index 09b42c06..62ac34c8 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/GarantiPosResponseDataMapperTest.php @@ -82,7 +82,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp $actualData = $this->responseDataMapper->mapPaymentResponse($responseData, $txType, $order); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -101,7 +106,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD ); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + if ([] !== $paymentResponse) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } + $this->assertArrayHasKey('3d_all', $actualData); + $this->assertIsArray($actualData['3d_all']); + $this->assertNotEmpty($actualData['3d_all']); unset($actualData['all'], $actualData['3d_all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -126,7 +141,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $re } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -147,7 +167,11 @@ public function testMapStatusResponse(array $responseData, array $expectedData): unset($actualData['refund_time'], $expectedData['refund_time']); unset($actualData['cancel_time'], $expectedData['cancel_time']); + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -184,6 +208,7 @@ public function testOrderMapHistoryResponse(array $responseData, array $expected $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -215,10 +240,14 @@ public function testMapHistoryResponse(array $responseData, array $expectedData) \ksort($expectedData['transactions'][$key]); } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); $this->assertArrayHasKey('all', $actualData); $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -228,7 +257,12 @@ public function testMapHistoryResponse(array $responseData, array $expectedData) public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -238,7 +272,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData): public function testMapCancelResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } diff --git a/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php index 5eb608de..89086df2 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/InterPosResponseDataMapperTest.php @@ -32,7 +32,7 @@ protected function setUp(): void $this->logger = $this->createMock(LoggerInterface::class); - $requestDataMapper = new InterPosRequestDataMapper( + $requestDataMapper = new InterPosRequestDataMapper( $this->createMock(EventDispatcherInterface::class), $this->createMock(CryptInterface::class), ); @@ -82,8 +82,14 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp $actualData = $this->responseDataMapper->mapPaymentResponse($responseData, $txType, $order); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + $this->assertArrayHasKey('all', $actualData); + if ([] !== $responseData) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -108,10 +114,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD unset($actualData['transaction_time'], $expectedData['transaction_time']); + $this->assertArrayHasKey('all', $actualData); + if ([] !== $paymentResponse) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } + $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); unset($actualData['all'], $actualData['3d_all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -123,7 +136,12 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD public function testMap3DPayResponseData(array $order, string $txType, array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->map3DPayResponseData($responseData, $txType, $order); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -135,7 +153,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $re public function testMap3DHostResponseData(array $order, string $txType, array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->map3DHostResponseData($responseData, $txType, $order); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -156,6 +179,9 @@ public function testMapStatusResponse(array $responseData, array $expectedData): unset($actualData['refund_time'], $expectedData['refund_time']); unset($actualData['cancel_time'], $expectedData['cancel_time']); + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); \ksort($expectedData); @@ -169,7 +195,12 @@ public function testMapStatusResponse(array $responseData, array $expectedData): public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -179,7 +210,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData): public function testMapCancelResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } diff --git a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php index 8348bfea..abe14d31 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/KuveytPosResponseDataMapperTest.php @@ -112,10 +112,12 @@ public function testMapPaymentResponse(string $txType, array $responseData, arra public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + $this->assertArrayHasKey('all', $actualData); $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + ksort($actualData); ksort($expectedData); $this->assertSame($expectedData, $actualData); @@ -127,10 +129,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData): public function testMapCancelResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($responseData); + $this->assertArrayHasKey('all', $actualData); $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + ksort($actualData); ksort($expectedData); $this->assertSame($expectedData, $actualData); @@ -179,7 +183,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + if ([] !== $paymentResponse) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } + $this->assertArrayHasKey('3d_all', $actualData); + $this->assertIsArray($actualData['3d_all']); + $this->assertNotEmpty($actualData['3d_all']); unset($actualData['all'], $actualData['3d_all']); + \ksort($actualData); \ksort($expectedData); $this->assertSame($expectedData, $actualData); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PayFlexCPV4PosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PayFlexCPV4PosResponseDataMapperTest.php index 785933a5..94a2d9ab 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PayFlexCPV4PosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PayFlexCPV4PosResponseDataMapperTest.php @@ -76,8 +76,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $ba $actualData = $this->responseDataMapper->map3DPayResponseData($bankResponse, $txType, $order); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php index ec6ed1a1..45d8d53a 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PayFlexV4PosResponseDataMapperTest.php @@ -83,7 +83,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD ); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + if ([] !== $paymentResponse) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } + $this->assertArrayHasKey('3d_all', $actualData); + $this->assertIsArray($actualData['3d_all']); + $this->assertNotEmpty($actualData['3d_all']); unset($actualData['all'], $actualData['3d_all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -97,7 +107,12 @@ public function testMapPaymentResponse(string $txType, array $responseData, arra $actualData = $this->responseDataMapper->mapPaymentResponse($responseData, $txType, []); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -109,7 +124,12 @@ public function testMapPaymentResponse(string $txType, array $responseData, arra public function testMapCancelResponse(array $paymentResponse, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($paymentResponse); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -119,7 +139,12 @@ public function testMapCancelResponse(array $paymentResponse, array $expectedDat public function testMapRefundResponse(array $paymentResponse, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($paymentResponse); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -133,7 +158,12 @@ public function testMapStatusResponse(array $responseData, array $expectedData): $this->assertEquals($expectedData['cancel_time'], $actualData['cancel_time']); unset($actualData['refund_time'], $expectedData['refund_time']); unset($actualData['cancel_time'], $expectedData['cancel_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PayForPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PayForPosResponseDataMapperTest.php index 000e5383..4a1bbd0e 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PayForPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PayForPosResponseDataMapperTest.php @@ -85,7 +85,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -104,7 +109,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD ); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + if ([] !== $paymentResponse) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } + $this->assertArrayHasKey('3d_all', $actualData); + $this->assertIsArray($actualData['3d_all']); + $this->assertNotEmpty($actualData['3d_all']); unset($actualData['all'], $actualData['3d_all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -118,7 +133,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $re $actualData = $this->responseDataMapper->map3DPayResponseData($responseData, $txType, $order); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -132,7 +152,12 @@ public function testMap3DHostResponseData(array $order, string $txType, array $r $actualData = $this->responseDataMapper->map3DHostResponseData($responseData, $txType, $order); $this->assertEquals($expectedData['transaction_time'], $actualData['transaction_time']); unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -153,7 +178,11 @@ public function testMapStatusResponse(array $responseData, array $expectedData): unset($actualData['refund_time'], $expectedData['refund_time']); unset($actualData['cancel_time'], $expectedData['cancel_time']); + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -187,7 +216,11 @@ public function testMapOrderHistoryResponse(array $responseData, array $expected \ksort($expectedData['transactions'][$key]); } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -219,7 +252,11 @@ public function testMapHistoryResponse(array $responseData, array $expectedData) \ksort($expectedData['transactions'][$key]); } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -229,7 +266,12 @@ public function testMapHistoryResponse(array $responseData, array $expectedData) public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -239,7 +281,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData): public function testMapCancelResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -270,7 +317,7 @@ public static function paymentTestDataProvider(): array 'amount' => 1.01, 'auth_code' => 'S77788', 'ref_ret_num' => '230422096719', - 'batch_num' => null, + 'batch_num' => null, 'proc_return_code' => '00', 'status' => 'approved', 'status_detail' => 'approved', diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php index 4d6e4cf7..fa88632f 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PosNetResponseDataMapperTest.php @@ -84,7 +84,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -107,10 +112,16 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD unset($actualData['transaction_time'], $expectedData['transaction_time']); + $this->assertArrayHasKey('all', $actualData); + if ([] !== $paymentResponse) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } $this->assertArrayHasKey('3d_all', $actualData); $this->assertIsArray($actualData['3d_all']); $this->assertNotEmpty($actualData['3d_all']); unset($actualData['all'], $actualData['3d_all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -131,7 +142,11 @@ public function testMapStatusResponse(array $responseData, array $expectedData): unset($actualData['refund_time'], $expectedData['refund_time']); unset($actualData['cancel_time'], $expectedData['cancel_time']); + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -143,7 +158,12 @@ public function testMapStatusResponse(array $responseData, array $expectedData): public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } diff --git a/tests/Unit/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapperTest.php index 2377133b..2757dd86 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/PosNetV1PosResponseDataMapperTest.php @@ -86,7 +86,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -110,7 +115,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + if ([] !== $paymentResponse) { + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } + $this->assertArrayHasKey('3d_all', $actualData); + $this->assertIsArray($actualData['3d_all']); + $this->assertNotEmpty($actualData['3d_all']); unset($actualData['all'], $actualData['3d_all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -132,7 +147,11 @@ public function testMapStatusResponse(array $responseData, array $expectedData): unset($actualData['refund_time'], $expectedData['refund_time']); unset($actualData['cancel_time'], $expectedData['cancel_time']); + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -144,7 +163,12 @@ public function testMapStatusResponse(array $responseData, array $expectedData): public function testMapCancelResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -154,7 +178,12 @@ public function testMapCancelResponse(array $responseData, array $expectedData): public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -212,7 +241,7 @@ public static function paymentTestDataProvider(): iterable 'amount' => 1.01, 'auth_code' => null, 'ref_ret_num' => null, - 'batch_num' => null, + 'batch_num' => null, 'proc_return_code' => '0127', 'status' => 'declined', 'status_detail' => null, @@ -308,7 +337,7 @@ public static function paymentTestDataProvider(): iterable 'amount' => 1.01, 'auth_code' => '449324', 'ref_ret_num' => '159044932490000231', - 'batch_num' => null, + 'batch_num' => null, 'proc_return_code' => '00', 'status' => 'approved', 'status_detail' => 'approved', diff --git a/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php index b3531111..754b3301 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/ToslaPosResponseDataMapperTest.php @@ -86,7 +86,12 @@ public function testMapPaymentResponse(array $order, string $txType, array $resp } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -106,7 +111,12 @@ public function testMap3DPayResponseData(array $order, string $txType, array $re } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -125,7 +135,12 @@ public function testMap3DHostResponseData(array $order, string $txType, array $r } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -149,7 +164,11 @@ public function testMapStatusResponse(array $responseData, array $expectedData): unset($actualData['cancel_time'], $expectedData['cancel_time']); } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($actualData); \ksort($expectedData); $this->assertSame($expectedData, $actualData); @@ -161,7 +180,12 @@ public function testMapStatusResponse(array $responseData, array $expectedData): public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -171,7 +195,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData): public function testMapCancelResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -206,7 +235,11 @@ public function testMapOrderHistoryResponse(array $responseData, array $expected } } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -253,7 +286,7 @@ public static function paymentDataProvider(): iterable 'currency' => 'TRY', 'amount' => 1.01, 'ref_ret_num' => null, - 'batch_num' => null, + 'batch_num' => null, 'proc_return_code' => '00', 'status' => 'approved', 'status_detail' => 'approved', @@ -288,7 +321,7 @@ public static function paymentDataProvider(): iterable 'currency' => 'TRY', 'amount' => 1.01, 'ref_ret_num' => null, - 'batch_num' => null, + 'batch_num' => null, 'proc_return_code' => '00', 'status' => 'approved', 'status_detail' => 'approved', @@ -323,7 +356,7 @@ public static function paymentDataProvider(): iterable 'currency' => 'TRY', 'amount' => 1.01, 'ref_ret_num' => null, - 'batch_num' => null, + 'batch_num' => null, 'proc_return_code' => null, 'status' => 'declined', 'status_detail' => 'transaction_not_found', @@ -359,7 +392,7 @@ public static function paymentDataProvider(): iterable 'currency' => 'TRY', 'amount' => 1.01, 'ref_ret_num' => null, - 'batch_num' => null, + 'batch_num' => null, 'proc_return_code' => null, 'status' => 'declined', 'status_detail' => null, diff --git a/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php b/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php index 2b3c15b0..c14cf171 100644 --- a/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php +++ b/tests/Unit/DataMapper/ResponseDataMapper/VakifKatilimPosResponseDataMapperTest.php @@ -93,7 +93,12 @@ public function testMapPaymentResponse(string $txType, array $responseData, arra } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -117,7 +122,17 @@ public function testMap3DPaymentData(array $order, string $txType, array $threeD } unset($actualData['transaction_time'], $expectedData['transaction_time']); + + $this->assertArrayHasKey('all', $actualData); + if ([] !== $paymentResponse) { + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); + } + $this->assertArrayHasKey('3d_all', $actualData); + $this->assertIsArray($actualData['3d_all']); + $this->assertNotEmpty($actualData['3d_all']); unset($actualData['all'], $actualData['3d_all']); + ksort($expectedData); ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -137,7 +152,11 @@ public function testMap3DHostResponseData(array $order, string $txType, array $r unset($actualData['transaction_time'], $expectedData['transaction_time']); + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -155,7 +174,12 @@ public function testMap3DPayResponseData(): void public function testMapRefundResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapRefundResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -165,7 +189,12 @@ public function testMapRefundResponse(array $responseData, array $expectedData): public function testMapCancelResponse(array $responseData, array $expectedData): void { $actualData = $this->responseDataMapper->mapCancelResponse($responseData); + + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -184,7 +213,11 @@ public function testMapStatusResponse(array $responseData, array $expectedData): unset($actualData['refund_time'], $expectedData['refund_time']); unset($actualData['cancel_time'], $expectedData['cancel_time']); + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + \ksort($expectedData); \ksort($actualData); $this->assertSame($expectedData, $actualData); @@ -218,7 +251,11 @@ public function testMapHistoryResponse(array $responseData, array $expectedData) \ksort($expectedData['transactions'][$key]); } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); } @@ -277,7 +314,11 @@ public function testMapOrderHistoryResponse(array $responseData, array $expected \ksort($expectedData['transactions'][$key]); } + $this->assertArrayHasKey('all', $actualData); + $this->assertIsArray($actualData['all']); + $this->assertNotEmpty($actualData['all']); unset($actualData['all']); + $this->assertSame($expectedData, $actualData); }