Example #1
0
 public function testConvert()
 {
     $fixturePath = __DIR__ . '/_files/';
     $dom = new \DOMDocument();
     $dom->loadXML(file_get_contents($fixturePath . 'config.xml'));
     $expectedResult = (include $fixturePath . 'converted_config.php');
     $this->assertEquals($expectedResult, $this->_model->convert($dom));
 }
Example #2
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());
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function convert($source)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'convert');
     if (!$pluginInfo) {
         return parent::convert($source);
     } else {
         return $this->___callPlugins('convert', func_get_args(), $pluginInfo);
     }
 }
Example #4
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();
 }