/**
  * @param int $customerId
  * @param bool $vaultEnabled
  * @dataProvider customerIdProvider
  */
 public function testGetConfig($customerId, $vaultEnabled)
 {
     $storeId = 1;
     $vaultPaymentCode = 'vault_payment';
     $expectedConfiguration = ['vault' => [$vaultPaymentCode => ['is_enabled' => $vaultEnabled]]];
     $this->session->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $this->storeManager->expects(static::exactly(2))->method('getStore')->willReturn($this->store);
     $this->store->expects(static::exactly(2))->method('getId')->willReturn($storeId);
     $this->paymentDataHelper->expects(static::once())->method('getStoreMethods')->with($storeId)->willReturn([$this->vaultPayment]);
     $this->vaultPayment->expects(static::once())->method('getCode')->willReturn($vaultPaymentCode);
     $this->vaultPayment->expects($customerId !== null ? static::once() : static::never())->method('isActive')->with($storeId)->willReturn($vaultEnabled);
     static::assertEquals($expectedConfiguration, $this->vaultConfigProvider->getConfig());
 }
 /**
  * @param int $id
  * @param bool $isVaultEnabled
  *
  * @dataProvider customerIdProvider
  */
 public function testGetConfig($customerId, $vaultEnabled)
 {
     $storeId = 1;
     $paymentProviderCode = 'concrete_vault_provider';
     $expectedConfiguration = [VaultPaymentInterface::CODE => ['vault_provider_code' => $paymentProviderCode, 'is_enabled' => $vaultEnabled]];
     $vaultMethod = $this->getMock(VaultPaymentInterface::class);
     $storeManager = $this->getMock(StoreManagerInterface::class);
     $store = $this->getMock(StoreInterface::class);
     $customerSession = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock();
     $customerSession->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $storeManager->expects(static::once())->method('getStore')->with(null)->willReturn($store);
     $store->expects(static::once())->method('getId')->willReturn($storeId);
     $vaultMethod->expects($customerId !== null ? static::once() : static::never())->method('isActive')->with($storeId)->willReturn($vaultEnabled);
     $vaultMethod->expects(static::once())->method('getProviderCode')->with($storeId)->willReturn($paymentProviderCode);
     $vaultCards = new VaultConfigProvider($storeManager, $vaultMethod, $customerSession);
     static::assertEquals($expectedConfiguration, $vaultCards->getConfig());
 }
Esempio n. 3
0
 /**
  * @param array $config
  * @param bool $expected
  * @covers \Magento\BraintreeTwo\Block\Form::isVaultEnabled
  * @dataProvider vaultConfigProvider
  */
 public function testIsVaultEnabled(array $config, $expected)
 {
     $this->vaultConfigProvider->expects(static::once())->method('getConfig')->willReturn([VaultPaymentInterface::CODE => $config]);
     static::assertEquals($expected, $this->block->isVaultEnabled());
 }