Esempio n. 1
0
 public function testgetConfiguration()
 {
     $this->_fileManagerMock->expects($this->once())->method('getFileList')->will($this->returnValue(array('testFile')));
     $this->_fileManagerMock->expects($this->once())->method('getContents')->with('testFile')->will($this->returnValue('<config><system><tabs></tabs></system></config>'));
     $parsedArray = array('config' => array('system' => array('tabs')));
     $this->_parserMock->expects($this->once())->method('parse')->with($this->isInstanceOf('DOMDocument'))->will($this->returnValue($parsedArray));
     $transformedArray = array('value' => 'expected');
     $this->_mapperMock->expects($this->once())->method('transform')->with($parsedArray)->will($this->returnValue($transformedArray));
     $this->assertEquals(array('testFile' => $transformedArray), $this->_model->getConfiguration());
 }
Esempio n. 2
0
$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();
}