예제 #1
0
 /**
  * Run mess detector on code
  *
  * @return void
  */
 public function testCodeMess()
 {
     $reportFile = self::$reportDir . '/phpmd_report.txt';
     $codeMessDetector = new CodeMessDetector(realpath(__DIR__ . '/_files/phpmd/ruleset.xml'), $reportFile);
     if (!$codeMessDetector->canRun()) {
         $this->markTestSkipped('PHP Mess Detector is not available.');
     }
     $result = $codeMessDetector->run(self::getWhitelist(['php']));
     $output = "";
     if (file_exists($reportFile)) {
         $output = file_get_contents($reportFile);
     }
     $this->assertEquals(Command::EXIT_SUCCESS, $result, "PHP Code Mess has found error(s):" . PHP_EOL . $output);
     // delete empty reports
     if (file_exists($reportFile)) {
         unlink($reportFile);
     }
 }
예제 #2
0
 /**
  * Run mess detector on code
  *
  * @return void
  */
 public function testCodeMess()
 {
     $reportFile = self::$reportDir . '/phpmd_report.xml';
     $codeMessDetector = new CodeMessDetector(realpath(__DIR__ . '/_files/phpmd/ruleset.xml'), $reportFile);
     if (!$codeMessDetector->canRun()) {
         $this->markTestSkipped('PHP Mess Detector is not available.');
     }
     self::setupFileLists();
     $this->assertEquals(Command::EXIT_SUCCESS, $codeMessDetector->run(self::$whiteList), "PHP Code Mess has found error(s): See detailed report in {$reportFile}");
     // delete empty reports
     unlink($reportFile);
 }
예제 #3
0
 /**
  * Run mess detector on code
  *
  * @param array $whiteList
  * @return void
  * @dataProvider whiteListDataProvider
  */
 public function testCodeMess($whiteList)
 {
     if (count($whiteList) == 1) {
         $formattedPath = preg_replace('~/~', '_', preg_replace('~' . self::$pathToSource . '~', '', $whiteList[0]));
     } else {
         $formattedPath = '_app_lib';
     }
     $reportFile = self::$reportDir . '/phpmd_report' . $formattedPath . '.xml';
     $codeMessDetector = new CodeMessDetector(realpath(__DIR__ . '/_files/phpmd/ruleset.xml'), $reportFile);
     if (!$codeMessDetector->canRun()) {
         $this->markTestSkipped('PHP Mess Detector is not available.');
     }
     $this->assertEquals(PHP_PMD_TextUI_Command::EXIT_SUCCESS, $codeMessDetector->run($whiteList, self::$blackList), "PHP Code Mess has found error(s): See detailed report in {$reportFile}");
     // delete empty reports
     unlink($reportFile);
 }
예제 #4
0
 public function testPhpMdAvailability()
 {
     $this->assertTrue(self::$_messDetector->canRun(), 'PHP Mess Detector command is not available.');
 }