mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Updating code coverage tools to use raw data which includes dead and uncovered line data.
This commit is contained in:
parent
9a20a2344b
commit
75d7146bd0
3 changed files with 6 additions and 4 deletions
|
@ -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 <<<HTML
|
||||
<h2>$filename Code coverage: $percent%</h2>
|
||||
<div class="code-coverage-results">
|
||||
|
|
|
@ -176,7 +176,7 @@ class CakeHtmlReporter extends CakeBaseReporter implements PHPUnit_Framework_Tes
|
|||
echo $this->_paintLinks();
|
||||
echo '</div>';
|
||||
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
|
||||
$coverage = $result->getCodeCoverageInformation();
|
||||
$coverage = $result->getRawCodeCoverageInformation();
|
||||
echo $this->paintCoverage($coverage);
|
||||
}
|
||||
$this->paintDocumentEnd();
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue