/** * @param string $xmlString * @dataProvider convertWithInvalidDomDataProvider * @expectedException \Exception */ public function testConvertWithInvalidDom($xmlString) { $dom = new \DOMDocument(); try { $dom->loadXML($xmlString); $this->_converter->convert($dom); } catch (\PHPUnit_Framework_Error $ex) { // do nothing because we expect \Exception but not \PHPUnit_Framework_Error } }
/** * Loads the full module list information. Excludes modules specified in $exclude. * * @param array $exclude * @throws \Magento\Framework\Exception\LocalizedException * @return array */ public function load(array $exclude = []) { $result = []; foreach ($this->getModuleConfigs() as list($file, $contents)) { try { $this->parser->loadXML($contents); } catch (\Magento\Framework\Exception\LocalizedException $e) { throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Invalid Document: %1%2 Error: %3', [$file, PHP_EOL, $e->getMessage()]), $e); } $data = $this->converter->convert($this->parser->getDom()); $name = key($data); if (!in_array($name, $exclude)) { $result[$name] = $data[$name]; } } return $this->sortBySequence($result); }
/** * Loads the full module list information * * @throws \Magento\Framework\Exception * @return array */ public function load() { $result = []; $dir = $this->filesystem->getDirectoryRead(DirectoryList::MODULES); foreach ($dir->search('*/*/etc/module.xml') as $file) { $contents = $dir->readFile($file); try { $this->parser->loadXML($contents); } catch (\Magento\Framework\Exception $e) { throw new \Magento\Framework\Exception('Invalid Document: ' . $file . PHP_EOL . ' Error: ' . $e->getMessage(), $e->getCode(), $e); } $data = $this->converter->convert($this->parser->getDom()); $name = key($data); $result[$name] = $data[$name]; } return $this->sortBySequence($result); }
/** * @param string $xmlString * @dataProvider testConvertWithInvalidDomDataProvider * @expectedException \Exception */ public function testConvertWithInvalidDom($xmlString) { $dom = new \DOMDocument(); $dom->loadXML($xmlString); $this->_converter->convert($dom); }