Exemple #1
0
 public function testCreateConfigurationGeneratesConfiguration()
 {
     $dom = new \DOMDocument();
     $dom->loadXML(preg_replace('/\\n|\\s{4}/', '', file_get_contents(__DIR__ . '/_files/convertedConfiguration.xml')));
     $stripComments = new \DOMXPath($dom);
     foreach ($stripComments->query('//comment()') as $comment) {
         $comment->parentNode->removeChild($comment);
     }
     $dom->formatOutput = true;
     $dom->preserveWhiteSpace = false;
     $expectedXml = $dom->saveXML();
     $this->_fileManagerMock->expects($this->once())->method('write')->with($this->stringContains('system.xml'), $expectedXml);
     $this->_formatterMock->expects($this->once())->method('parseString')->will($this->returnCallback(function ($xml) {
         $dom = new \DOMDocument();
         $dom->loadXML($xml);
         $dom->preserveWhiteSpace = false;
         $dom->formatOutput = true;
         return $dom->saveXML();
     }));
     $this->_loggerMock->expects($this->once())->method('add')->with('someFile', \Magento\Tools\Migration\System\Configuration\AbstractLogger::FILE_KEY_INVALID);
     $this->_model->createConfiguration('someFile', include __DIR__ . '/_files/mappedConfiguration.php');
 }
$rootDir = realpath(__DIR__ . '../../../../../../');
require __DIR__ . '/../../../../../app/autoload.php';
\Magento\Framework\Filesystem\FileResolver::addIncludePath([$rootDir . '/lib', $rootDir . '/dev']);
$defaultReportFile = 'report.log';
try {
    $options = new \Zend_Console_Getopt(['mode|w' => "Application mode.  Preview mode is default. If set to 'write' - file system is updated", 'output|f-w' => "Report output type. Report is flushed to console by default." . "If set to 'file', report is written to file /log/report.log"]);
    $writerFactory = new Factory();
    $fileManager = new FileManager(new \Magento\Tools\Migration\System\FileReader(), $writerFactory->getWriter($options->getOption('mode')));
    $loggerFactory = new Logger\Factory();
    $logger = $loggerFactory->getLogger($options->getOption('output'), $defaultReportFile, $fileManager);
    $generator = new Generator(new Formatter(), $fileManager, $logger);
    $fieldMapper = new Field();
    $groupMapper = new Group($fieldMapper);
    $sectionMapper = new Section($groupMapper);
    $tabMapper = new Tab();
    $mapper = new Mapper($tabMapper, $sectionMapper);
    $parser = new Parser();
    $reader = new Reader($fileManager, $parser, $mapper);
    foreach ($reader->getConfiguration() as $file => $config) {
        $generator->createConfiguration($file, $config);
        $fileManager->remove($file);
    }
    $logger->report();
} catch (\Zend_Console_Getopt_Exception $e) {
    echo $e->getUsageMessage();
    exit;
} catch (InvalidArgumentException $exp) {
    echo $exp->getMessage();
} catch (Exception $exp) {
    echo $exp->getMessage();
}