-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Can Demiralp
committed
Jan 31, 2025
1 parent
2ff0636
commit 3cbb7ca
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
/** | ||
* | ||
* Adyen Payment module (https://www.adyen.com/) | ||
* | ||
* Copyright (c) 2025 Adyen N.V. (https://www.adyen.com/) | ||
* See LICENSE.txt for license details. | ||
* | ||
* Author: Adyen <magento@adyen.com> | ||
*/ | ||
|
||
namespace Adyen\Payment\Test\Unit\Model\Api; | ||
|
||
use Adyen\Payment\Helper\GiftcardPayment; | ||
use Adyen\Payment\Model\Api\GuestAdyenGiftcard; | ||
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
use Magento\Quote\Model\MaskedQuoteIdToQuoteIdInterface; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
class GuestAdyenGiftcardTest extends AbstractAdyenTestCase | ||
{ | ||
protected ?GuestAdyenGiftcard $guestAdyenGiftcard; | ||
protected MockObject|GiftcardPayment $giftcardPaymentHelperMock; | ||
protected MockObject|MaskedQuoteIdToQuoteIdInterface $maskedQuoteIdToQuoteId; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
$this->giftcardPaymentHelperMock = $this->createMock(GiftcardPayment::class); | ||
$this->maskedQuoteIdToQuoteId = $this->createMock(MaskedQuoteIdToQuoteIdInterface::class); | ||
|
||
$this->guestAdyenGiftcard = new GuestAdyenGiftcard( | ||
$this->giftcardPaymentHelperMock, | ||
$this->maskedQuoteIdToQuoteId | ||
); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
protected function tearDown(): void | ||
{ | ||
$this->guestAdyenGiftcard = null; | ||
} | ||
|
||
/** | ||
* @return void | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function testGetRedeemedGiftcards() | ||
{ | ||
$cartId = 'abc_123456789_xyz'; | ||
$quoteId = 1; | ||
$mockResponse = '{}'; | ||
|
||
$this->maskedQuoteIdToQuoteId->expects($this->once()) | ||
->method('execute') | ||
->with($cartId) | ||
->willReturn($quoteId); | ||
|
||
$this->giftcardPaymentHelperMock->expects($this->once()) | ||
->method('fetchRedeemedGiftcards') | ||
->with($quoteId) | ||
->willReturn($mockResponse); | ||
|
||
$result = $this->guestAdyenGiftcard->getRedeemedGiftcards($cartId); | ||
$this->assertIsString($result); | ||
} | ||
} |