Esempio n. 1
0
 /**
  * @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();
 }
Esempio n. 2
0
 /**
  * Test the successful execution of the 'read' method
  *
  * @return void
  */
 public function testReadSuccessNotValidatedCase()
 {
     $content = '<config><item name="test1"></item><item name="test2"></item></config>';
     $expectedResult = ['result_data'];
     $fileList = ['file' => $content];
     $this->fileResolverMock->expects($this->once())->method('get')->with('system.xml', 'global')->willReturn($fileList);
     $this->compilerMock->expects($this->once())->method('compile')->with($this->isInstanceOf('\\DOMElement'), $this->isInstanceOf('Magento\\Framework\\DataObject'), $this->isInstanceOf('Magento\\Framework\\DataObject'));
     $this->converterMock->expects($this->once())->method('convert')->with($this->isInstanceOf('\\DOMDocument'))->willReturn($expectedResult);
     $this->assertEquals($expectedResult, $this->reader->read());
 }
Esempio n. 3
0
 /**
  * @covers \Magento\Framework\App\Config\Initial\Reader::read
  */
 public function testReadValidConfig()
 {
     $testXmlFilesList = array(file_get_contents($this->_filePath . 'initial_config1.xml'), file_get_contents($this->_filePath . 'initial_config2.xml'));
     $expectedConfig = array('data' => array(), 'metadata' => array());
     $this->_fileResolverMock->expects($this->at(0))->method('get')->with('config.xml', 'global')->will($this->returnValue($testXmlFilesList));
     $this->_converterMock->expects($this->once())->method('convert')->with($this->anything())->will($this->returnValue($expectedConfig));
     $this->rootDirectory->expects($this->any())->method('getRelativePath')->will($this->returnArgument(0));
     $this->rootDirectory->expects($this->any())->method('readFile')->will($this->returnValue('<config></config>'));
     $this->assertEquals($expectedConfig, $this->_model->read());
 }
Esempio n. 4
0
 protected function setUp()
 {
     $this->_fileResolverMock = $this->getMock('Magento\\Framework\\Config\\FileResolverInterface');
     $this->_fileResolverMock->expects($this->once())->method('get')->with('address_formats.xml', 'scope')->will($this->returnValue([file_get_contents(__DIR__ . '/_files/formats_one.xml'), file_get_contents(__DIR__ . '/_files/formats_two.xml')]));
     $this->_converter = $this->getMock('Magento\\Customer\\Model\\Address\\Config\\Converter', ['convert']);
     $moduleReader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', ['getModuleDir'], [], '', false);
     $moduleReader->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Customer')->will($this->returnValue('stub'));
     $this->_schemaLocator = new \Magento\Customer\Model\Address\Config\SchemaLocator($moduleReader);
     $this->_validationState = $this->getMock('Magento\\Framework\\Config\\ValidationStateInterface');
     $this->_validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false));
     $this->_model = new \Magento\Customer\Model\Address\Config\Reader($this->_fileResolverMock, $this->_converter, $this->_schemaLocator, $this->_validationState);
 }
Esempio n. 5
0
 protected function setUp()
 {
     $this->_fileResolverMock = $this->getMock('Magento\\Framework\\Config\\FileResolverInterface');
     $this->_fileResolverMock->expects($this->once())->method('get')->with('catalog_attributes.xml', 'scope')->will($this->returnValue(array(file_get_contents(__DIR__ . '/_files/attributes_config_one.xml'), file_get_contents(__DIR__ . '/_files/attributes_config_two.xml'))));
     $this->_converter = $this->getMock('Magento\\Catalog\\Model\\Attribute\\Config\\Converter', array('convert'));
     $moduleReader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', array('getModuleDir'), array(), '', false);
     $moduleReader->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Catalog')->will($this->returnValue('stub'));
     $this->_schemaLocator = new \Magento\Catalog\Model\Attribute\Config\SchemaLocator($moduleReader);
     $this->_validationState = $this->getMock('Magento\\Framework\\Config\\ValidationStateInterface');
     $this->_validationState->expects($this->once())->method('isValidated')->will($this->returnValue(false));
     $this->_model = new \Magento\Catalog\Model\Attribute\Config\Reader($this->_fileResolverMock, $this->_converter, $this->_schemaLocator, $this->_validationState);
 }
Esempio n. 6
0
 protected function setUp()
 {
     $this->_fileResolverMock = $this->getMock('Magento\\Framework\\Config\\FileResolverInterface');
     $this->_fileResolverMock->expects($this->once())->method('get')->with('pdf.xml', 'scope')->will($this->returnValue([file_get_contents(__DIR__ . '/_files/pdf_one.xml'), file_get_contents(__DIR__ . '/_files/pdf_two.xml')]));
     $this->_converter = $this->getMock('Magento\\Sales\\Model\\Order\\Pdf\\Config\\Converter', ['convert']);
     $moduleReader = $this->getMock('Magento\\Framework\\Module\\Dir\\Reader', ['getModuleDir'], [], '', false);
     $moduleReader->expects($this->once())->method('getModuleDir')->with('etc', 'Magento_Sales')->will($this->returnValue('stub'));
     $this->_schemaLocator = new \Magento\Sales\Model\Order\Pdf\Config\SchemaLocator($moduleReader);
     $this->_validationState = $this->getMock('Magento\\Framework\\Config\\ValidationStateInterface');
     $this->_validationState->expects($this->any())->method('isValidationRequired')->willReturn(false);
     $this->_model = new \Magento\Sales\Model\Order\Pdf\Config\Reader($this->_fileResolverMock, $this->_converter, $this->_schemaLocator, $this->_validationState, 'pdf.xml');
 }
Esempio n. 7
0
 /**
  * @covers \Magento\Framework\App\Config\Initial\Reader::read
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessageRegExp /Invalid XML in file \w+/
  */
 public function testReadInvalidConfig()
 {
     $this->createModelAndVerifyConstructor();
     $this->prepareDomFactoryMock();
     $testXmlFilesList = [file_get_contents($this->filePath . 'invalid_config.xml'), file_get_contents($this->filePath . 'initial_config2.xml')];
     $expectedConfig = ['data' => [], 'metadata' => []];
     $this->fileResolverMock->expects($this->at(0))->method('get')->with('config.xml', 'global')->will($this->returnValue($testXmlFilesList));
     $this->converterMock->expects($this->never())->method('convert')->with($this->anything())->will($this->returnValue($expectedConfig));
     $this->model->read();
 }