From 7435b15a3c18441fc5925ff0a55d9ab53731b165 Mon Sep 17 00:00:00 2001 From: Can Demiralp Date: Thu, 3 Oct 2024 17:42:07 +0200 Subject: [PATCH] [ECP-9506] Update unit tests --- .../Http/Client/TransactionPaymentTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Test/Unit/Gateway/Http/Client/TransactionPaymentTest.php b/Test/Unit/Gateway/Http/Client/TransactionPaymentTest.php index 492c65ebc..3b1be8746 100644 --- a/Test/Unit/Gateway/Http/Client/TransactionPaymentTest.php +++ b/Test/Unit/Gateway/Http/Client/TransactionPaymentTest.php @@ -11,6 +11,7 @@ namespace Adyen\Payment\Test\Unit\Gateway\Http\Client; +use Adyen\AdyenException; use Adyen\Model\Checkout\ApplicationInfo; use Adyen\Model\Checkout\PaymentRequest; use Adyen\Model\Checkout\PaymentResponse as CheckoutPaymentResponse; @@ -87,6 +88,23 @@ public function testPlaceRequestWithResultCode() $this->assertEquals($requestBody, $result); } + public function testPlaceRequestWithoutResultCode() + { + $transferObjectMock = $this->createMock(TransferInterface::class); + + $requestBody = ['amount' => ['value' => 1000]]; + $transferObjectMock->method('getBody')->willReturn($requestBody); + $transferObjectMock->method('getClientConfig')->willReturn(['storeId' => 1]); + + $clientMock = $this->createMock(PaymentsApi::class); + $clientMock->method('payments')->willThrowException(new AdyenException()); + + $this->adyenHelperMock->method('initializePaymentsApi')->willReturn($clientMock); + + $response = $this->transactionPayment->placeRequest($transferObjectMock); + $this->assertArrayHasKey('errorCode', $response[0]); + } + public function testPlaceRequestGeneratesIdempotencyKey() { $requestBody = ['reference' => 'ABC12345', 'amount' => ['value' => 100], 'applicationInfo' => $this->applicationInfoMock];