Exemple #1
0
 /**
  * @inheritdoc
  */
 public function result(AnalysisResult $result)
 {
     $this->cli->br();
     $this->cli->inline('Writing HTML report in "./phphound/"... ');
     $history = new History($this->getOutputDirectory());
     $history->append($result);
     foreach ($result->toArray() as $filePath => $lines) {
         $this->writeFileHtml($filePath, $lines);
     }
     $this->writeIndexHtml($result, $history);
     $history->save();
     $this->cli->out('Done!');
 }
 /** @test */
 function it_doesnot_break_with_a_new_integration_setup_after_a_few_runs()
 {
     $directory = sys_get_temp_dir();
     $oldHistory = ['executions' => ['Aug 31 12:30', 'Sep 2 15:17'], 'historyData' => ['PHPMessDetector' => ['name' => 'PHPMessDetector', 'data' => [12, 3]], 'PHPCodeSniffer' => ['name' => 'PHPCodeSniffer', 'data' => [5, 2]], 'PHPCopyPasteDetector' => ['name' => 'PHPCopyPasteDetector', 'data' => [1, 1]]]];
     $data = ['File.php' => [111 => [['tool' => 'PHPMessDetector', 'type' => 'xxx', 'message' => 'xxx'], ['tool' => 'PHPCodeSniffer', 'type' => 'xxx', 'message' => 'xxx'], ['tool' => 'PHPCopyPasteDetector', 'type' => 'xxx', 'message' => 'xxx'], ['tool' => 'NewTool', 'type' => 'xxx', 'message' => 'xxx']]]];
     $newHistory = ['executions' => ['Aug 31 12:30', 'Sep 2 15:17', 'Sep 7 23:45'], 'historyData' => ['PHPMessDetector' => ['name' => 'PHPMessDetector', 'data' => [12, 3, 1]], 'PHPCodeSniffer' => ['name' => 'PHPCodeSniffer', 'data' => [5, 2, 1]], 'PHPCopyPasteDetector' => ['name' => 'PHPCopyPasteDetector', 'data' => [1, 1, 1]], 'NewTool' => ['name' => 'NewTool', 'data' => [0, 0, 1]]]];
     file_put_contents($directory . '/history.json', json_encode($oldHistory));
     $history = new History($directory);
     $result = $this->getMock('phphound\\AnalysisResult');
     $result->expects($this->once())->method('toArray')->willReturn($data);
     $history->append($result);
     $historyData = $history->getData();
     $this->assertEquals($newHistory['historyData'], $historyData['historyData']);
 }