objectManager = new ObjectManager($this); $this->vaultPaymentList = $this->createMock(PaymentMethodListInterface::class); $this->vaultPayment = $this->getMockForAbstractClass(VaultPaymentInterface::class); $this->storeManager = $this->createMock(StoreManagerInterface::class); $this->store = $this->createMock(StoreInterface::class); $this->customerTokenManagement = $this->getMockBuilder(CustomerTokenManagement::class) ->disableOriginalConstructor() ->getMock(); } public function testGetConfig() { $storeId = 1; $vaultProviderCode = 'vault_provider_code'; $expectedConfig = [ 'payment' => [ 'vault' => [ $vaultProviderCode . '_' . '0' => [ 'config' => ['token_code' => 'code'], 'component' => 'Vendor_Module/js/vault_component' ] ] ] ]; $token = $this->getMockForAbstractClass(PaymentTokenInterface::class); $tokenUiComponentProvider = $this->getMockForAbstractClass(TokenUiComponentProviderInterface::class); $tokenUiComponent = $this->getMockForAbstractClass(TokenUiComponentInterface::class); $this->storeManager->expects(static::once()) ->method('getStore') ->willReturn($this->store); $this->store->expects(static::once()) ->method('getId') ->willReturn($storeId); $this->vaultPaymentList->expects(static::once()) ->method('getActiveList') ->with($storeId) ->willReturn([$this->vaultPayment]); $this->vaultPayment->expects(static::once()) ->method('getProviderCode') ->willReturn($vaultProviderCode); $this->customerTokenManagement->expects(static::once()) ->method('getCustomerSessionTokens') ->willReturn([$token]); $token->expects(static::once()) ->method('getPaymentMethodCode') ->willReturn($vaultProviderCode); $tokenUiComponentProvider->expects(static::once()) ->method('getComponentForToken') ->with($token) ->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->customerTokenManagement, [ $vaultProviderCode => $tokenUiComponentProvider ] ); $this->objectManager->setBackwardCompatibleProperty( $configProvider, 'vaultPaymentList', $this->vaultPaymentList ); static::assertEquals($expectedConfig, $configProvider->getConfig()); } }