/** * @covers \Magento\Braintree\Block\Form::getCcAvailableTypes * @param string $countryId * @param array $availableTypes * @param array $expected * @dataProvider countryCardTypesDataProvider */ public function testGetCcAvailableTypes($countryId, array $availableTypes, array $expected) { $this->sessionQuote->expects(static::once())->method('getCountryId')->willReturn($countryId); $this->gatewayConfig->expects(static::once())->method('getAvailableCardTypes')->willReturn(self::$configCardTypes); $this->gatewayConfig->expects(static::once())->method('getCountryAvailableCardTypes')->with($countryId)->willReturn($availableTypes); $result = $this->block->getCcAvailableTypes(); static::assertEquals($expected, array_values($result)); }
public function testGetCcAvailableTypesWithCheckout() { $this->appStateMock->expects($this->once())->method('getAreaCode')->willReturn(''); $addressMock = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote\\Address')->disableOriginalConstructor()->setMethods(['getCountryId'])->getMock(); $addressMock->expects($this->once())->method('getCountryId')->willReturn('US'); $quoteMock = $this->getMockBuilder('\\Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods(['getBillingAddress'])->getMock(); $quoteMock->expects($this->once())->method('getBillingAddress')->willReturn($addressMock); $this->checkoutSessionMock->expects($this->once())->method('getQuote')->willReturn($quoteMock); $this->configMock->expects($this->once())->method('getApplicableCardTypes')->with('US')->willReturn(['VI', 'DI', 'MC', 'AE', 'JCB']); $this->paymentConfigMock->expects($this->once())->method('getCcTypes')->willReturn(['VI' => 'VI', 'DI' => 'DI', 'MC' => 'MC', 'AE' => 'AE', 'JCB' => 'JCB']); $result = $this->form->getCcAvailableTypes(); $this->assertSame($result, ['VI' => 'VI', 'DI' => 'DI', 'MC' => 'MC', 'AE' => 'AE', 'JCB' => 'JCB']); }