예제 #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();
 }
예제 #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());
 }
예제 #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'];
 }