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()); } }