Example #1
0
 /**
  * runShouldCallEachLintClassRunMethod
  * @author Alistair Stead
  * @test
  */
 public function runShouldCallEachLintClassRunMethod()
 {
     // Create a stub for the SomeClass class.
     $stub = $this->getMock('Zend_Tool_Framework_Response');
     // Configure the stub.
     $stub->expects($this->any())->method('appendContent')->will($this->returnArgument(0));
     $this->_lint->run($stub);
 }
Example #2
0
 /**
  * lintModuleStructureShouldEnvokeAddMessage
  * @author Alistair Stead
  * @group lintClassFiles
  * @test
  */
 public function lintModuleStructureShouldEnvokeAddMessage()
 {
     $testFilePath = $this->_invalidFixturePath . 'classfiles-config.xml';
     $xml = file_get_contents($testFilePath);
     $config = new SimpleXMLElement($xml);
     // Configure the stub.
     $this->_stubLint->expects($this->exactly(3))->method('addMessage')->will($this->returnArgument(0));
     $lint = new MageTool_Lint_Config();
     $lint->setlint($this->_stubLint);
     $lint->setFilePath($testFilePath);
     $lint->setConfig($config);
     $lint->lintModuleStructure();
 }
Example #3
0
 /**
  * Validate the Magento xml config using lint tests
  *
  * @return void
  * @author Alistair Stead
  **/
 public function lint($configFilePath = 'app/code/local', $lintFilePath = null)
 {
     $this->_bootstrap();
     // TODO search local file path and the supplied path for files that implement lint
     $lints = array('MageTool_Lint_Xml' => 'MageTool/Lint/Xml.php', 'MageTool_Lint_Config' => 'MageTool/Lint/Config.php', 'MageTool_Lint_System' => 'MageTool/Lint/System.php', 'MageTool_Lint_Adminhtml' => 'MageTool/Lint/Adminhtml.php', 'MageTool_Lint_Api' => 'MageTool/Lint/Api.php');
     $lintObjects = array();
     foreach ($lints as $lintClass => $includePath) {
         try {
             include_once $includePath;
             $lintTest = new $lintClass();
             $lintObjects[] = $lintTest;
         } catch (MageTool_Lint_Exception $e) {
             $this->_response->appendContent("{$e->getMessage()}", array('color' => array('red')));
         }
     }
     $lint = new MageTool_Lint();
     $lint->setPathFilter($configFilePath);
     // If an additional lint file path is supplied pass it to be loaded
     if (!is_null($lintFilePath)) {
         $lint->addLints($lintFilePath);
     } else {
         $lint->addLints($lintObjects);
     }
     $lint->run();
     foreach ($lint->getMessages() as $message) {
         $this->_response->appendContent("{$message->getLevel()}: {$message->getMessage()}", array('color' => array($message->getColour())));
     }
     $count = count($lint->getMessages());
     if ($count > 0) {
         $this->_response->appendContent("({$count}) Messages reported", array('color' => array('red')));
     } else {
         $this->_response->appendContent("No errors found", array('color' => array('green')));
     }
 }