Пример #1
0
 /**
  * Run the magento specific coding standards on the code
  *
  * @return void
  */
 public function testCodeStyle()
 {
     $reportFile = self::$reportDir . '/less_report.txt';
     $wrapper = new LessWrapper();
     $codeSniffer = new CodeSniffer(realpath(__DIR__ . '/_files/lesscs'), $reportFile, $wrapper);
     if (!$codeSniffer->canRun()) {
         $this->markTestSkipped('PHP Code Sniffer is not installed.');
     }
     $codeSniffer->setExtensions([LessWrapper::LESS_FILE_EXTENSION]);
     $fileList = PHPCodeTest::getWhitelist([LessWrapper::LESS_FILE_EXTENSION], __DIR__, __DIR__);
     $result = $codeSniffer->run($this->filterFiles($fileList));
     $this->assertEquals(0, $result, "PHP Code Sniffer has found {$result} error(s): See detailed report in {$reportFile}");
 }
Пример #2
0
 /**
  * Run the annotations sniffs on the code
  *
  * @return void
  * @todo Combine with normal code style at some point.
  */
 public function testAnnotationStandard()
 {
     $reportFile = self::$reportDir . '/phpcs_annotations_report.txt';
     $wrapper = new Wrapper();
     $codeSniffer = new CodeSniffer(realpath(__DIR__ . '/../../../../framework/Magento/ruleset.xml'), $reportFile, $wrapper);
     if (!$codeSniffer->canRun()) {
         $this->markTestSkipped('PHP Code Sniffer is not installed.');
     }
     $result = $codeSniffer->run(self::getWhitelist(['php']));
     $output = "";
     if (file_exists($reportFile)) {
         $output = file_get_contents($reportFile);
     }
     $this->assertEquals(0, $result, "PHP Code Sniffer has found {$result} error(s): " . PHP_EOL . $output);
 }
Пример #3
0
 public function testPhpCsAvailability()
 {
     $this->assertTrue(self::$_cmd->canRun(), 'PHP Code Sniffer command is not available.');
 }
Пример #4
0
 /**
  * Run the annotations sniffs on the code
  *
  * @return void
  * @todo Combine with normal code style at some point.
  */
 public function testAnnotationStandard()
 {
     $reportFile = self::$reportDir . '/phpcs_annotations_report.xml';
     $wrapper = new Wrapper();
     $codeSniffer = new CodeSniffer(realpath(__DIR__ . '/../../../../framework/Magento/ruleset.xml'), $reportFile, $wrapper);
     if (!$codeSniffer->canRun()) {
         $this->markTestSkipped('PHP Code Sniffer is not installed.');
     }
     self::setupFileLists('phpcs');
     $severity = 0;
     // Change to 5 to see the warnings
     $this->assertEquals(0, $result = $codeSniffer->run(self::$whiteList, self::$blackList, array('php'), $severity), "PHP Code Sniffer has found {$result} error(s): See detailed report in {$reportFile}");
 }
Пример #5
0
 /**
  * Run the annotations sniffs on the code
  *
  * @return void
  * @todo Combine with normal code style at some point.
  */
 public function testAnnotationStandard()
 {
     $reportFile = self::$reportDir . '/phpcs_annotations_report.xml';
     $warningSeverity = 5;
     $wrapper = new Wrapper();
     $codeSniffer = new CodeSniffer(realpath(__DIR__ . '/../../../../framework/Magento/ruleset.xml'), $reportFile, $wrapper);
     if (!$codeSniffer->canRun()) {
         $this->markTestSkipped('PHP Code Sniffer is not installed.');
     }
     self::setupFileLists('phpcs');
     // Scan for error amount
     $result = $codeSniffer->run(self::$whiteList, self::$blackList, array('php'), 0);
     // Rescan to generate report with warnings.
     $codeSniffer->run(self::$whiteList, self::$blackList, array('php'), $warningSeverity);
     // Fail if there are errors in report.
     $this->assertEquals(0, $result, "PHP Code Sniffer has found {$result} error(s): See detailed report in {$reportFile}");
 }