public function testUpdateReferences() { $testFile = $this->_varDir . 'layoutValid.xml'; copy($this->_testDir . 'layoutValid.xml', $testFile); $layouts = array($testFile); $this->_processor->getReferences($layouts); $this->_processor->writeToFile(); $expected = <<<EOF <?xml version="1.0"?> <list> <item type="reference" value="block"/> <item type="reference" value="container"/> <item type="block" value="another.block"/> <item type="block" value="block"/> <item type="container" value="another.container"/> <item type="container" value="container"/> </list> EOF; $this->assertEquals($expected, file_get_contents($this->_dictionaryPath)); $this->_processor->updateReferences($layouts); $this->assertFileEquals($this->_testDir . 'layoutValidExpectUpdated.xml', $testFile); }
if ($opt->dir) { $rootDir = realpath($opt->dir); } if (!file_exists($rootDir) || !is_dir($rootDir)) { throw new \Exception("Directory to process ({$rootDir}) not found"); } if (empty($opt->dictionary)) { throw new \Exception("Dictionary file is required"); } if (!empty($opt->process) && empty($opt->file) && empty($opt->overwrite)) { throw new \Exception("Overwrite option is required if you going to process multiple files"); } if (!file_exists($opt->dictionary)) { touch($opt->dictionary); } $processor = new Processor(new Formatter(), realpath($opt->dictionary)); $layouts = array(); if (!empty($opt->file) && file_exists($opt->file)) { $layouts = array(realpath($opt->file)); } else { $layouts = $processor->getLayoutFiles($rootDir); } if ($opt->collect) { $processor->getReferences($layouts)->writeToFile(); } if ($opt->process) { $processor->updateReferences($layouts, $opt->processor, $opt->overwrite); } exit(0); } catch (\Zend_Console_Getopt_Exception $e) { echo $e->getUsageMessage();