mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Switching back to using non raw code coverage data as it has been filtered by phpunit's filters. combining the data from phpunit into a singular cohesive report.
This commit is contained in:
parent
3c3655aefd
commit
ac318faf5a
4 changed files with 26 additions and 20 deletions
|
@ -61,7 +61,7 @@ class HtmlCoverageReportTest extends CakeTestCase {
|
|||
function testFilterCoverageDataByPathRemovingElements() {
|
||||
$data = array(
|
||||
array(
|
||||
'data' => array(
|
||||
'files' => array(
|
||||
TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php' => array(
|
||||
10 => -1,
|
||||
12 => 1
|
||||
|
@ -87,28 +87,37 @@ class HtmlCoverageReportTest extends CakeTestCase {
|
|||
function testFilterCoverageDataCorrectlyMergingValues() {
|
||||
$data = array(
|
||||
array(
|
||||
'data' => array(
|
||||
TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php' => array(
|
||||
10 => -1,
|
||||
'files' => array(
|
||||
'/something/dispatcher.php' => array(
|
||||
10 => 1,
|
||||
12 => 1
|
||||
),
|
||||
),
|
||||
'executable' => array(
|
||||
'/something/dispatcher.php' => array(
|
||||
10 => -1
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'data' => array(
|
||||
TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php' => array(
|
||||
'files' => array(
|
||||
'/something/dispatcher.php' => array(
|
||||
10 => 1,
|
||||
12 => -1,
|
||||
50 => 1,
|
||||
51 => -1
|
||||
),
|
||||
),
|
||||
'executable' => array(
|
||||
'/something/dispatcher.php' => array(
|
||||
12 => -1,
|
||||
51 => -1
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
$this->Coverage->setCoverage($data);
|
||||
$result = $this->Coverage->filterCoverageDataByPath(TEST_CAKE_CORE_INCLUDE_PATH);
|
||||
$result = $this->Coverage->filterCoverageDataByPath('/something/');
|
||||
|
||||
$path = TEST_CAKE_CORE_INCLUDE_PATH . 'dispatcher.php';
|
||||
$path = '/something/dispatcher.php';
|
||||
$this->assertTrue(isset($result[$path]));
|
||||
$this->assertEquals(1, $result[$path][10]);
|
||||
$this->assertEquals(1, $result[$path][12]);
|
||||
|
|
|
@ -120,20 +120,17 @@ class HtmlCoverageReport {
|
|||
public function filterCoverageDataByPath($path) {
|
||||
$files = array();
|
||||
foreach ($this->_rawCoverage as $testRun) {
|
||||
foreach ($testRun['data'] as $filename => $fileCoverage) {
|
||||
foreach ($testRun['files'] as $filename => $fileCoverage) {
|
||||
if (strpos($filename, $path) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$dead = isset($testRun['dead'][$filename]) ? $testRun['dead'][$filename] : array();
|
||||
$executable = isset($testRun['executable'][$filename]) ? $testRun['executable'][$filename] : array();
|
||||
|
||||
if (!isset($files[$filename])) {
|
||||
$files[$filename] = array();
|
||||
}
|
||||
foreach ($fileCoverage as $line => $value) {
|
||||
if (!isset($files[$filename][$line])) {
|
||||
$files[$filename][$line] = $value;
|
||||
} elseif ($files[$filename][$line] < $value) {
|
||||
$files[$filename][$line] = $value;
|
||||
}
|
||||
}
|
||||
$files[$filename] = $files[$filename] + $fileCoverage + $executable + $dead;
|
||||
}
|
||||
}
|
||||
ksort($files);
|
||||
|
|
|
@ -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->getRawCodeCoverageInformation();
|
||||
$coverage = $result->getCodeCoverageInformation();
|
||||
echo $this->paintCoverage($coverage);
|
||||
}
|
||||
$this->paintDocumentEnd();
|
||||
|
|
|
@ -162,7 +162,7 @@ class TestManager {
|
|||
*/
|
||||
protected function run($reporter, $codeCoverage = false) {
|
||||
$result = new PHPUnit_Framework_TestResult;
|
||||
$result->collectRawCodeCoverageInformation($codeCoverage);
|
||||
$result->collectCodeCoverageInformation($codeCoverage);
|
||||
$result->addListener($reporter);
|
||||
$reporter->paintHeader();
|
||||
$this->getTestSuite()->run($result);
|
||||
|
|
Loading…
Add table
Reference in a new issue