예제 #1
0
 /**
  * Run copy paste detector on code
  *
  * @return void
  */
 public function testCopyPaste()
 {
     $reportFile = self::$reportDir . '/phpcpd_report.xml';
     $copyPasteDetector = new CopyPasteDetector($reportFile);
     if (!$copyPasteDetector->canRun()) {
         $this->markTestSkipped('PHP Copy/Paste Detector is not available.');
     }
     $blackList = [];
     foreach (glob(__DIR__ . '/_files/phpcpd/blacklist/*.txt') as $list) {
         $blackList = array_merge($blackList, file($list, FILE_IGNORE_NEW_LINES));
     }
     $copyPasteDetector->setBlackList($blackList);
     $result = $copyPasteDetector->run([BP]);
     $output = "";
     if (file_exists($reportFile)) {
         $output = file_get_contents($reportFile);
     }
     $this->assertTrue($result, "PHP Copy/Paste Detector has found error(s):" . PHP_EOL . $output);
 }
예제 #2
0
 /**
  * Run copy paste detector on code
  *
  * @return void
  */
 public function testCopyPaste()
 {
     $reportFile = self::$reportDir . '/phpcpd_report.xml';
     $copyPasteDetector = new CopyPasteDetector($reportFile);
     if (!$copyPasteDetector->canRun()) {
         $this->markTestSkipped('PHP Copy/Paste Detector is not available.');
     }
     self::setupFileLists();
     $blackList = array();
     foreach (glob(__DIR__ . '/_files/phpcpd/blacklist/*.txt') as $list) {
         $blackList = array_merge($blackList, file($list, FILE_IGNORE_NEW_LINES));
     }
     $this->assertTrue($copyPasteDetector->run(array(), $blackList), "PHP Copy/Paste Detector has found error(s): See detailed report in {$reportFile}");
 }