Skip to content

Commit

Permalink
[ECP-9506] Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Demiralp committed Oct 3, 2024
1 parent 371562b commit 7435b15
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Test/Unit/Gateway/Http/Client/TransactionPaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 7435b15

Please sign in to comment.