fileResolver = $this->getMockForAbstractClass( \Magento\Framework\Config\FileResolverInterface::class ); $this->converter = $this->createMock(\Magento\Paypal\Model\Config\Rules\Converter::class); $this->schemaLocator = $this->getMockForAbstractClass( \Magento\Framework\Config\SchemaLocatorInterface::class ); $this->validationState = $this->getMockForAbstractClass( \Magento\Framework\Config\ValidationStateInterface::class ); $this->helper = $this->createMock(\Magento\Paypal\Helper\Backend::class); } /** * @param string $countryCode * @param string $xml * @param string $expected * @dataProvider dataProviderReadExistingCountryConfig */ public function testReadExistingCountryConfig($countryCode, $xml, $expected) { $this->helper->expects($this->once()) ->method('getConfigurationCountryCode') ->willReturn($countryCode); $this->fileResolver->expects($this->once()) ->method('get') ->with($this->equalTo($expected)) ->willReturn($xml); $this->reader = new \Magento\Paypal\Model\Config\Rules\Reader( $this->fileResolver, $this->converter, $this->schemaLocator, $this->validationState, $this->helper ); $this->reader->read(); } /** * @param string $countryCode * @param string $xml * @param string $expected * @dataProvider dataProviderReadOtherCountryConfig */ public function testReadOtherCountryConfig($countryCode, $xml, $expected) { $this->helper->expects($this->once()) ->method('getConfigurationCountryCode') ->willReturn($countryCode); $this->fileResolver->expects($this->at(0)) ->method('get') ->willReturn([]); $this->fileResolver->expects($this->at(1)) ->method('get') ->with($this->equalTo($expected)) ->willReturn($xml); $this->reader = new Reader( $this->fileResolver, $this->converter, $this->schemaLocator, $this->validationState, $this->helper ); $this->reader->read(); } /** * @return array */ public function dataProviderReadExistingCountryConfig() { return [ ['us', [''], 'adminhtml/rules/payment_us.xml'], ['ca', [''], 'adminhtml/rules/payment_ca.xml'], ['au', [''], 'adminhtml/rules/payment_au.xml'], ['gb', [''], 'adminhtml/rules/payment_gb.xml'], ['jp', [''], 'adminhtml/rules/payment_jp.xml'], ['fr', [''], 'adminhtml/rules/payment_fr.xml'], ['it', [''], 'adminhtml/rules/payment_it.xml'], ['es', [''], 'adminhtml/rules/payment_es.xml'], ['hk', [''], 'adminhtml/rules/payment_hk.xml'], ['nz', [''], 'adminhtml/rules/payment_nz.xml'], ['de', [''], 'adminhtml/rules/payment_de.xml'], ]; } /** * @return array */ public function dataProviderReadOtherCountryConfig() { return [ ['no', [''], 'adminhtml/rules/payment_other.xml'], ]; } }