Exemplo n.º 1
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();
     $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();
 }
Exemplo n.º 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());
 }
Exemplo n.º 3
0
 /**
  * @param \Magento\Framework\App\Config\Initial\Reader $reader
  * @param \Magento\Framework\App\Cache\Type\Config $cache
  */
 public function __construct(\Magento\Framework\App\Config\Initial\Reader $reader, \Magento\Framework\App\Cache\Type\Config $cache)
 {
     $data = $cache->load(self::CACHE_ID);
     if (!$data) {
         $data = $reader->read();
         $cache->save(serialize($data), self::CACHE_ID);
     } else {
         $data = unserialize($data);
     }
     $this->_data = $data['data'];
     $this->_metadata = $data['metadata'];
 }
Exemplo n.º 4
0
 /**
  * @param FileResolverInterface $fileResolver  The file resolver
  * @param ConverterInterface    $converter     Converter
  * @param SchemaLocator         $schemaLocator The schema locator
  * @param DomFactory            $domFactory    The DOM factory
  * @param string                $fileName      The file name
  */
 public function __construct(FileResolverInterface $fileResolver, ConverterInterface $converter, SchemaLocator $schemaLocator, DomFactory $domFactory, $fileName = self::FILE_NAME)
 {
     parent::__construct($fileResolver, $converter, $schemaLocator, $domFactory, $fileName);
 }