public function testGetConfig() { $storeId = 1; $vaultProviderCode = 'vault_provider_code'; $expectedConfig = ['payment' => [VaultPaymentInterface::CODE => [VaultPaymentInterface::CODE . '_item_' . '0' => ['config' => ['token_code' => 'code'], 'component' => 'Vendor_Module/js/vault_component']]]]; $tokenMock = $this->getMockBuilder(PaymentTokenInterface::class)->getMockForAbstractClass(); $tokenUiComponentProvider = $this->getMock(TokenUiComponentProviderInterface::class); $tokenUiComponent = $this->getMock(TokenUiComponentInterface::class); $this->vaultPayment->expects(static::once())->method('getProviderCode')->with($storeId)->willReturn($vaultProviderCode); $this->storeManager->expects(static::once())->method('getStore')->with(null)->willReturn($this->store); $this->store->expects(static::once())->method('getId')->willReturn($storeId); $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(true); $this->customerTokenManagement->expects(self::once())->method('getCustomerSessionTokens')->willReturn([$tokenMock]); $tokenUiComponentProvider->expects(static::once())->method('getComponentForToken')->with($tokenMock)->willReturn($tokenUiComponent); $tokenUiComponent->expects(static::once())->method('getConfig')->willReturn(['token_code' => 'code']); $tokenUiComponent->expects(static::once())->method('getName')->willReturn('Vendor_Module/js/vault_component'); $configProvider = new TokensConfigProvider($this->storeManager, $this->vaultPayment, $this->customerTokenManagement, [$vaultProviderCode => $tokenUiComponentProvider]); static::assertEquals($expectedConfig, $configProvider->getConfig()); }
public function testGetConfigNoActiveVaultProvider() { $customerId = 1; $storeId = 1; $this->customerSessionMock->expects(self::once())->method('getCustomerId')->willReturn($customerId); $this->storeManager->expects(static::once())->method('getStore')->with(null)->willReturn($this->store); $this->store->expects(static::once())->method('getId')->willReturn($storeId); $this->vaultPayment->expects(static::once())->method('isActive')->with($storeId)->willReturn(false); $this->paymentTokenRepositoryMock->expects(self::never())->method('getList'); $configProvider = new TokensConfigProvider($this->customerSessionMock, $this->paymentTokenRepositoryMock, $this->filterBuilderMock, $this->searchCriteriaBuilderMock, $this->storeManager, $this->vaultPayment); $config = $configProvider->getConfig(); self::assertEmpty($config); }