mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Fixing HtmlCoverageReport so it properly enables the test subject class as best it can.
This commit is contained in:
parent
bfcfa4c06e
commit
ed68368201
2 changed files with 19 additions and 6 deletions
|
@ -90,7 +90,6 @@ abstract class BaseCoverageReport {
|
|||
|
||||
/**
|
||||
* Gets the base path that the files we are interested in live in.
|
||||
* If appTest ist
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -72,8 +72,7 @@ HTML;
|
|||
$coveringTests = array();
|
||||
foreach ($coverageData[$lineno] as $test) {
|
||||
$testReflection = new ReflectionClass(current(explode('::', $test['id'])));
|
||||
list($fileBasename,) = explode('.', basename($testReflection->getFileName()), 2);
|
||||
$this->_testNames[] = $fileBasename;
|
||||
$this->_testNames[] = $this->_guessSubjectName($testReflection);
|
||||
$coveringTests[] = $test['id'];
|
||||
}
|
||||
$class = 'covered';
|
||||
|
@ -86,13 +85,28 @@ HTML;
|
|||
}
|
||||
|
||||
$percentCovered = round(100 * $covered / $total, 2);
|
||||
|
||||
$output .= $this->coverageHeader($filename, $percentCovered);
|
||||
$output .= implode("", $diff);
|
||||
$output .= $this->coverageFooter();
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess the classname the test was for based on the test case filename.
|
||||
*
|
||||
* @param ReflectionClass $testReflection.
|
||||
* @return string Possible test subject name.
|
||||
*/
|
||||
protected function _guessSubjectName($testReflection) {
|
||||
$basename = basename($testReflection->getFilename());
|
||||
if (strpos($basename, '.test') !== false) {
|
||||
list($subject, ) = explode('.', $basename, 2);
|
||||
return $subject;
|
||||
}
|
||||
$subject = str_replace('Test.php', '', $basename);
|
||||
return $subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the html for a single line in the html diff.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue