mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Making coverage reports show what tests covered the line being hovered over. Updating CSS to help facilitate hover effects.
This commit is contained in:
parent
687eab9528
commit
cb9d6f478d
2 changed files with 19 additions and 3 deletions
|
@ -190,7 +190,11 @@ HTML;
|
|||
|
||||
foreach ($fileLines as $lineno => $line) {
|
||||
$class = 'ignored';
|
||||
$coveringTests = array();
|
||||
if (isset($coverageData['covered'][$lineno])) {
|
||||
$coveringTests = PHPUnit_Util_CodeCoverage::getCoveringTests(
|
||||
$this->_rawCoverage, $filename, $lineno
|
||||
);
|
||||
$class = 'covered';
|
||||
$covered++;
|
||||
$total++;
|
||||
|
@ -200,7 +204,7 @@ HTML;
|
|||
} elseif (isset($coverageData['dead'][$lineno])) {
|
||||
$class .= ' dead';
|
||||
}
|
||||
$diff[] = $this->_paintLine($line, $lineno, $class);
|
||||
$diff[] = $this->_paintLine($line, $lineno, $class, $coveringTests);
|
||||
}
|
||||
|
||||
$percentCovered = round(100 * $covered / $total, 2);
|
||||
|
@ -216,10 +220,19 @@ HTML;
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _paintLine($line, $linenumber, $class) {
|
||||
protected function _paintLine($line, $linenumber, $class, $coveringTests) {
|
||||
$coveredBy = '';
|
||||
if (!empty($coveringTests)) {
|
||||
$coveredBy = "Covered by:\n";
|
||||
foreach ($coveringTests as &$test) {
|
||||
$coveredBy .= $test->getName() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf(
|
||||
'<div class="code-line %s"><span class="line-num">%s</span><span class="content">%s</span></div>',
|
||||
'<div class="code-line %s" title="%s"><span class="line-num">%s</span><span class="content">%s</span></div>',
|
||||
$class,
|
||||
$coveredBy,
|
||||
$linenumber,
|
||||
htmlspecialchars($line)
|
||||
);
|
||||
|
|
|
@ -90,6 +90,9 @@
|
|||
div.code-coverage-results div.uncovered span.content { background:#ecc; }
|
||||
div.code-coverage-results div.covered span.content { background:#cec; }
|
||||
div.code-coverage-results div.ignored span.content { color:#aaa; }
|
||||
div.code-coverage-results div:hover { background:#e8e8e8;}
|
||||
div.code-coverage-results div.covered:hover span.content { background:#b4edb4;}
|
||||
div.code-coverage-results div.uncovered:hover span.content { background:#edb4b4;}
|
||||
div.code-coverage-results span.line-num {
|
||||
color:#666;
|
||||
display:block;
|
||||
|
|
Loading…
Reference in a new issue