Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/module-vault/Test/Unit/Block/Customer/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-vault/Test/Unit/Block/Customer/AccountTokensTest.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Vault\Test\Unit\Block\Customer;

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Block\Customer\AccountTokens;
use Magento\Vault\Model\AccountPaymentTokenFactory;
use Magento\Vault\Model\CreditCardTokenFactory;
use Magento\Vault\Model\CustomerTokenManagement;
use Magento\Vault\Model\PaymentToken;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class AccountTokensTest extends TestCase
{
    /**
     * @var CustomerTokenManagement|MockObject
     */
    private $tokenManagement;

    /**
     * @var AccountTokens
     */
    private $block;

    /**
     * @var ObjectManager
     */
    private $objectManager;

    protected function setUp(): void
    {
        $this->objectManager = new ObjectManager($this);

        $this->tokenManagement = $this->getMockBuilder(CustomerTokenManagement::class)
            ->disableOriginalConstructor()
            ->setMethods(['getCustomerSessionTokens'])
            ->getMock();

        $this->block = $this->objectManager->getObject(AccountTokens::class, [
            'customerTokenManagement' => $this->tokenManagement
        ]);
    }

    /**
     * @covers \Magento\Vault\Block\Customer\AccountTokens::getPaymentTokens
     */
    public function testGetPaymentTokens()
    {
        $cardToken = $this->objectManager->getObject(PaymentToken::class, [
            'data' => [PaymentTokenInterface::TYPE => CreditCardTokenFactory::TOKEN_TYPE_CREDIT_CARD]
        ]);
        $token = $this->objectManager->getObject(PaymentToken::class, [
            'data' => [PaymentTokenInterface::TYPE => AccountPaymentTokenFactory::TOKEN_TYPE_ACCOUNT]
        ]);
        $this->tokenManagement->expects(static::once())
            ->method('getCustomerSessionTokens')
            ->willReturn([$cardToken, $token]);

        $actual = $this->block->getPaymentTokens();
        static::assertCount(1, $actual);

        /** @var PaymentTokenInterface $actualToken */
        $actualToken = array_pop($actual);
        static::assertEquals(AccountPaymentTokenFactory::TOKEN_TYPE_ACCOUNT, $actualToken->getType());
    }
}

Spamworldpro Mini