Skip to content

Commit

Permalink
[ECP-8972] Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Can Demiralp committed Mar 20, 2024
1 parent 59c15f2 commit 4d99e0a
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions Test/Unit/Model/Resolver/GetAdyenRedeemedGiftcardsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
use Adyen\Payment\Helper\GiftcardPayment;
use Adyen\Payment\Model\Resolver\GetAdyenRedeemedGiftcards;
use Adyen\Payment\Test\Unit\AbstractAdyenTestCase;
use PHPUnit\Framework\TestCase;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Query\Resolver\ContextInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Quote\Model\QuoteIdMask;
use Magento\Quote\Model\QuoteIdMaskFactory;
use Adyen\Payment\Test\Model\Resolver\Order;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;

class GetAdyenRedeemedGiftcardsTest extends AbstractAdyenTestCase
{
Expand All @@ -32,9 +32,11 @@ protected function setUp(): void
{
$this->giftcardPaymentMock = $this->createMock(GiftcardPayment::class);
$this->jsonSerializerMock = $this->createMock(Json::class);
$this->quoteIdMaskFactoryMock = $this->createGeneratedMock(QuoteIdMaskFactory::class);
$this->quoteIdMaskFactoryMock = $this->createGeneratedMock(
QuoteIdMaskFactory::class,
['create']
);
$this->quoteIdMaskMock = $this->createMock(QuoteIdMask::class);

$this->quoteIdMaskFactoryMock->method('create')->willReturn($this->quoteIdMaskMock);

$this->getAdyenRedeemedGiftcards = new GetAdyenRedeemedGiftcards(
Expand All @@ -46,11 +48,9 @@ protected function setUp(): void

public function testSuccessfulRetrievalOfRedeemedGiftCardDetailsWithValidCartId()
{

$fieldMock = $this->createMock(\Magento\Framework\GraphQl\Config\Element\Field::class);
$contextMock = $this->createMock(\Magento\Framework\GraphQl\Config\Element\Field::class);
$resolveInfoMock = $this->createMock(\Magento\Framework\GraphQl\Schema\Type\ResolveInfo::class);

$fieldMock = $this->createMock(Field::class);
$contextMock = $this->createMock(ContextInterface::class);
$resolveInfoMock = $this->createMock(ResolveInfo::class);

$cartId = 'test_cart_id';
$quoteId = 0;
Expand All @@ -77,10 +77,16 @@ public function testSuccessfulRetrievalOfRedeemedGiftCardDetailsWithValidCartId(
->with($redeemedGiftcardsJson)
->willReturn($redeemedGiftcardsData);


$result = $this->getAdyenRedeemedGiftcards->resolve($fieldMock, $contextMock, $resolveInfoMock, [], $args);

$this->assertEquals(['redeemedGiftcards' => $redeemedGiftcardsData['redeemedGiftcards'], 'remainingAmount' => $redeemedGiftcardsData['remainingAmount'], 'totalDiscount' => $redeemedGiftcardsData['totalDiscount']], $result);
$this->assertEquals(
[
'redeemedGiftcards' => $redeemedGiftcardsData['redeemedGiftcards'],
'remainingAmount' => $redeemedGiftcardsData['remainingAmount'],
'totalDiscount' => $redeemedGiftcardsData['totalDiscount']
],
$result
);
}
}

Expand Down

0 comments on commit 4d99e0a

Please sign in to comment.