Ejemplo n.º 1
0
 /**
  * @param string $xmlFile
  * @param string $newXmlFile
  * @dataProvider mergeExceptionDataProvider
  * @expectedException Magento_Exception
  */
 public function testMergeException($xmlFile, $newXmlFile)
 {
     $xml = file_get_contents(__DIR__ . "/_files/dom/{$xmlFile}");
     $newXml = file_get_contents(__DIR__ . "/_files/dom/{$newXmlFile}");
     $config = new Magento_Config_Dom($xml, array());
     $config->merge($newXml);
 }
Ejemplo n.º 2
0
 /**
  * Merge the config XML-files
  *
  * @param array $configFiles
  * @throws Exception if a non-existing or invalid XML-file passed
  */
 protected function _merge($configFiles)
 {
     $domConfig = new Magento_Config_Dom($this->_getInitialXml(), $this->_getIdAttributes());
     foreach ($configFiles as $file) {
         if (!file_exists($file)) {
             throw new Exception("File does not exist: {$file}");
         }
         $domConfig->merge(file_get_contents($file));
         if (!$domConfig->validate($this->getSchemaFile(), $errors)) {
             $message = "Invalid XML-file: {$file}\n";
             /** @var libXMLError $error */
             foreach ($errors as $error) {
                 $message .= "{$error->message} Line: {$error->line}\n";
             }
             throw new Exception($message);
         }
     }
     $this->_dom = $domConfig->getDom();
 }