Exemplo n.º 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', Tools_Migration_System_Configuration_LoggerAbstract::FILE_KEY_VALID);
     $this->_model->createConfiguration('someFile', include __DIR__ . '/_files/mappedConfiguration.php');
 }
Exemplo n.º 2
0
 * @category   Tools
 * @package    system_configuration
 * @copyright  Copyright (c) 2012 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
$rootDir = realpath(__DIR__ . '../../../..');
require __DIR__ . '/../../../app/autoload.php';
Magento_Autoload_IncludePath::addIncludePath(array($rootDir . '/lib', $rootDir . '/dev'));
$defaultReportFile = 'report.log';
try {
    $options = new Zend_Console_Getopt(array('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 Tools_Migration_System_Writer_Factory();
    $fileManager = new Tools_Migration_System_FileManager(new Tools_Migration_System_FileReader(), $writerFactory->getWriter($options->getOption('mode')));
    $loggerFactory = new Tools_Migration_System_Configuration_Logger_Factory();
    $logger = $loggerFactory->getLogger($options->getOption('output'), $defaultReportFile, $fileManager);
    $generator = new Tools_Migration_System_Configuration_Generator(new Tools_Migration_System_Configuration_Formatter(), $fileManager, $logger);
    $fieldMapper = new Tools_Migration_System_Configuration_Mapper_Field();
    $groupMapper = new Tools_Migration_System_Configuration_Mapper_Group($fieldMapper);
    $sectionMapper = new Tools_Migration_System_Configuration_Mapper_Section($groupMapper);
    $tabMapper = new Tools_Migration_System_Configuration_Mapper_Tab();
    $mapper = new Tools_Migration_System_Configuration_Mapper($tabMapper, $sectionMapper);
    $parser = new Tools_Migration_System_Configuration_Parser();
    $reader = new Tools_Migration_System_Configuration_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;