/** * 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); } }
/** * 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); }
/** * 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); }
public function testPhpMdAvailability() { $this->assertTrue(self::$_messDetector->canRun(), 'PHP Mess Detector command is not available.'); }