예제 #1
0
 public function runReport()
 {
     echo "\nPHP_Testability by Edson Medina\n";
     $start_ts = microtime(TRUE);
     // run
     $report = new RootContext($this->path);
     $files = (new FileIteratorFactory())->create($this->verbose);
     if (!empty($this->excludeDirs)) {
         $files->setExcludedDirs(explode(',', $this->excludeDirs));
     }
     echo "Analysing code on \"" . $this->path . "\"...\n";
     $files->iterate($report);
     $scan_time = number_format(microtime(TRUE) - $start_ts, 2);
     echo " OK ({$scan_time}s).\n\n";
     // generate HTML report
     $htmlReport = new HTMLReport($report, $this->reportDir);
     $htmlReport->generate();
     // generate CSV report
     if ($this->shouldOutputCSV) {
         $csvReport = new CSVReport($report, $this->reportDir);
         $csvReport->generate();
     }
     // output info
     $total_time = number_format(microtime(TRUE) - $start_ts, 2);
     echo "Done (Total: {$total_time}s).\n\n";
     echo $files->getProcessedFilesCount() . " processed files.\n";
     echo number_format(memory_get_peak_usage() / 1024 / 1024, 2) . " Mbytes of memory used\n\n";
 }
 /**
  * @covers edsonmedina\php_testability\HTMLReport::convertPathToRelative
  * @uses edsonmedina\php_testability\Contexts\DirectoryContext::__construct
  */
 public function testConvertPathToRelative()
 {
     $report = new HTMLReport(new DirectoryContext('/Whatever/path/files/are'), '', false);
     $this->assertEquals('is/fine.php', $report->convertPathToRelative('/Whatever/path/files/are/is/fine.php'));
 }