Exemplo n.º 1
0
 /** @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']);
 }
Exemplo n.º 2
0
 /**
  * Create HTML report index page.
  * @param AnalysisResult $result result data object.
  * @return void
  */
 protected function writeIndexHtml(AnalysisResult $result, History $history)
 {
     $files = [];
     foreach ($result->toArray() as $fileName => $lines) {
         if (!isset($files[$fileName])) {
             $files[$fileName] = 0;
         }
         foreach ($lines as $issues) {
             $files[$fileName] += count($issues);
         }
     }
     $chartData = $history->getData();
     $indexHtml = $this->renderView('index', ['files' => $files, 'executions' => $chartData['executions'], 'historyData' => array_values($chartData['historyData'])]);
     $fileName = $this->getOutputDirectory() . '/index.html';
     $file = new SplFileObject($fileName, 'w');
     $file->fwrite($indexHtml);
 }