Skip to content

Commit

Permalink
unit test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hossam-adyen committed Feb 21, 2024
1 parent 0f48b6d commit dba5fe3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion Plugin/PaymentVaultDeleteToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ public function beforeDelete(PaymentTokenRepositoryInterface $subject, PaymentTo
);

$response = $recurringService->disable(new DisableRequest($request));
$this->dataHelper->logResponse($response);

$responseData = json_decode(json_encode($response->jsonSerialize()), true);
$this->dataHelper->logResponse($responseData);

} catch (AdyenException $e) {
$this->adyenLogger->error(sprintf(
'Error while attempting to disable token with id %s: %s',
Expand Down
2 changes: 1 addition & 1 deletion Test/Unit/Gateway/Http/Client/TransactionCancelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function testCancellationWithAdyenApiException()
$result = $this->transactionCancel->placeRequest($this->transferObjectMock);

// Assert
$this->assertSame($result, []);
$this->assertSame($result, ['error' => 'API exception']);
}

public function testCancellationWithMultipleRequests()
Expand Down
10 changes: 7 additions & 3 deletions Test/Unit/Plugin/PaymentVaultDeleteTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@

namespace Adyen\Payment\Test\Plugin;

use Adyen\Model\Recurring\DisableResult;
use Adyen\Payment\Helper\Data;
use Adyen\Payment\Logger\AdyenLogger;
use Adyen\Payment\Plugin\PaymentVaultDeleteToken;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
use Adyen\Payment\Helper\Requests;
use Adyen\Service\RecurringApi;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Api\PaymentTokenRepositoryInterface;
use Magento\Store\Model\StoreManagerInterface;
Expand Down Expand Up @@ -64,11 +66,13 @@ public function testSuccessfullyDisableValidAdyenPaymentTokenBeforeDeletion()
$this->vaultHelperMock->method('isAdyenPaymentCode')->willReturn(true);

$clientMock = $this->createMock(Client::class);
$recurringServiceMock = $this->createMock(Recurring::class);
$recurringServiceMock = $this->createMock(RecurringApi::class);
$this->dataHelperMock->method('initializeAdyenClient')->willReturn($clientMock);
$this->dataHelperMock->method('createAdyenRecurringService')->willReturn($recurringServiceMock);
$this->dataHelperMock->method('initializeRecurringApi')->willReturn($recurringServiceMock);

$recurringServiceMock->expects($this->once())->method('disable')->willReturn(['response' => 'success']);
$recurringServiceMock->expects($this->once())
->method('disable')
->willReturn(new DisableResult(['response' => 'success']));

$this->paymentVaultDeleteToken = new PaymentVaultDeleteToken(
$storeManagerMock,
Expand Down

0 comments on commit dba5fe3

Please sign in to comment.