From 75d7146bd0323bee80f488d05e6b7d346ac64aa7 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Sun, 9 May 2010 01:15:57 -0400 Subject: [PATCH] Updating code coverage tools to use raw data which includes dead and uncovered line data. --- cake/tests/lib/coverage/html_coverage_report.php | 6 ++++-- cake/tests/lib/reporter/cake_html_reporter.php | 2 +- cake/tests/lib/test_manager.php | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cake/tests/lib/coverage/html_coverage_report.php b/cake/tests/lib/coverage/html_coverage_report.php index e4440b995..6122acd3d 100644 --- a/cake/tests/lib/coverage/html_coverage_report.php +++ b/cake/tests/lib/coverage/html_coverage_report.php @@ -120,7 +120,7 @@ class HtmlCoverageReport { public function filterCoverageDataByPath($path) { $files = array(); foreach ($this->_rawCoverage as $testRun) { - foreach ($testRun['files'] as $filename => $fileCoverage) { + foreach ($testRun['data'] as $filename => $fileCoverage) { if (strpos($filename, $path) !== 0) { continue; } @@ -136,6 +136,7 @@ class HtmlCoverageReport { } } } + ksort($files); return $files; } @@ -214,7 +215,7 @@ class HtmlCoverageReport { $diff[] = $this->_paintLine($line, $lineno, $class); } - $percentCovered = round($covered / $total, 2); + $percentCovered = round(100 * $covered / $total, 2); $output .= $this->coverageHeader($filename, $percentCovered); $output .= implode("", $diff); @@ -243,6 +244,7 @@ class HtmlCoverageReport { * @return void */ public function coverageHeader($filename, $percent) { + $filename = basename($filename); return <<$filename Code coverage: $percent%
diff --git a/cake/tests/lib/reporter/cake_html_reporter.php b/cake/tests/lib/reporter/cake_html_reporter.php index 3c4d33548..d36ea0d06 100755 --- a/cake/tests/lib/reporter/cake_html_reporter.php +++ b/cake/tests/lib/reporter/cake_html_reporter.php @@ -176,7 +176,7 @@ class CakeHtmlReporter extends CakeBaseReporter implements PHPUnit_Framework_Tes echo $this->_paintLinks(); echo '
'; if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) { - $coverage = $result->getCodeCoverageInformation(); + $coverage = $result->getRawCodeCoverageInformation(); echo $this->paintCoverage($coverage); } $this->paintDocumentEnd(); diff --git a/cake/tests/lib/test_manager.php b/cake/tests/lib/test_manager.php index 67e35bc61..bef977808 100644 --- a/cake/tests/lib/test_manager.php +++ b/cake/tests/lib/test_manager.php @@ -162,7 +162,7 @@ class TestManager { */ protected function run($reporter, $codeCoverage = false) { $result = new PHPUnit_Framework_TestResult; - $result->collectCodeCoverageInformation($codeCoverage); + $result->collectRawCodeCoverageInformation($codeCoverage); $result->addListener($reporter); $reporter->paintHeader(); $this->getTestSuite()->run($result);