/** * Create block for own configuration for each payment token * * @return void */ protected function createVaultBlocks() { $icons = $this->cardConfigProvider->getIcons(); $payments = $this->tokensProvider->getTokensComponents(); foreach ($payments as $key => $payment) { $this->addChild($key, $payment->getName(), array_merge(['id' => $key, 'icons' => $icons], $payment->getConfig())); } }
/** * @covers \Magento\Vault\Model\Ui\Adminhtml\TokensConfigProvider::getTokensComponents */ public function testGetTokensComponentsEmptyComponentProvider() { $storeId = 1; $customerId = 2; $code = 'vault_payment'; $this->session->expects(static::once())->method('getCustomerId')->willReturn($customerId); $this->initStoreMock(); $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(true); $this->vaultPayment->expects(static::once())->method('getProviderCode')->with($storeId)->willReturn($code); $this->paymentTokenRepository->expects(static::never())->method('getList'); $configProvider = new TokensConfigProvider($this->session, $this->paymentTokenRepository, $this->filterBuilder, $this->searchCriteriaBuilder, $this->storeManager, $this->vaultPayment, $this->dateTimeFactory); static::assertEmpty($configProvider->getTokensComponents()); }
/** * @covers \Magento\Vault\Model\Ui\Adminhtml\TokensConfigProvider::getTokensComponents */ public function testGetTokensComponentsNotExistsCustomer() { $vaultPaymentCode = 'vault_payment'; $this->store = $this->getMock(StoreInterface::class); $this->storeManager = $this->getMock(StoreManagerInterface::class); $this->session->expects(static::once())->method('getCustomerId')->willReturn(null); $this->storeManager->expects(static::never())->method('getStore'); $configProvider = new TokensConfigProvider($this->session, $this->paymentTokenRepository, $this->filterBuilder, $this->searchCriteriaBuilder, $this->storeManager, $this->dateTimeFactory); static::assertEmpty($configProvider->getTokensComponents($vaultPaymentCode)); }