/** * @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(); }
/** * Substitute payment section with PayPal configs * * @param \Magento\Backend\Model\Config\Structure $subject * @param \Closure $proceed * @param array $pathParts * @return \Magento\Backend\Model\Config\Structure\ElementInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function aroundGetElementByPathParts(\Magento\Backend\Model\Config\Structure $subject, \Closure $proceed, array $pathParts) { $isSectionChanged = $pathParts[0] == 'payment'; if ($isSectionChanged) { $requestedCountrySection = 'payment_' . strtolower($this->_helper->getConfigurationCountryCode()); if (in_array($requestedCountrySection, self::getPaypalConfigCountries())) { $pathParts[0] = $requestedCountrySection; } else { $pathParts[0] = 'payment_other'; } } /** @var \Magento\Backend\Model\Config\Structure\ElementInterface $result */ $result = $proceed($pathParts); if ($isSectionChanged && isset($result)) { if ($result instanceof \Magento\Backend\Model\Config\Structure\Element\Section) { $result->setData(array_merge($result->getData(), ['showInDefault' => true, 'showInWebsite' => true, 'showInStore' => true]), $this->_scopeDefiner->getScope()); } } return $result; }
/** * Assert result of getConfigurationCountryCode method * * @param string $expected */ private function _configurationCountryCodeAssertResult($expected) { $this->assertEquals($expected, $this->_helper->getConfigurationCountryCode()); }
/** * Constructor * * @param FileResolverInterface $fileResolver * @param Converter $converter * @param SchemaLocatorInterface $schemaLocator * @param ValidationStateInterface $validationState * @param Backend $helper * @param string $fileName * @param array $idAttributes * @param string $domDocumentClass * @param string $defaultScope */ public function __construct(FileResolverInterface $fileResolver, Converter $converter, SchemaLocatorInterface $schemaLocator, ValidationStateInterface $validationState, Backend $helper, $fileName = 'adminhtml/rules/payment_{country}.xml', $idAttributes = [], $domDocumentClass = 'Magento\\Framework\\Config\\Dom', $defaultScope = 'primary') { $fileName = str_replace('{country}', strtolower($helper->getConfigurationCountryCode()), $fileName); parent::__construct($fileResolver, $converter, $schemaLocator, $validationState, $fileName, $idAttributes, $domDocumentClass, $defaultScope); }
/** * Prepare helper for test * * @param string $countryCode */ private function _getElementByPathPartsPrepareHelper($countryCode) { $this->_helper->expects($this->once())->method('getConfigurationCountryCode')->will($this->returnValue($countryCode)); }