Skip to content

Commit

Permalink
Filter out files which has no coverable line inside.
Browse files Browse the repository at this point in the history
  • Loading branch information
jails committed Oct 16, 2016
1 parent d3664c0 commit c7411ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions spec/Suite/Reporter/Coverage/Metrics.spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,12 @@

expect($metrics->get('Kahlan\Spec\Fixture\Reporter\Coverage\ImplementsCoverageInterface'))->toBe(null);

expect($collector->export())->toBe([
str_replace('/', DS, 'spec/Fixture/Reporter/Coverage/ImplementsCoverage.php') => [
7 => 1
]
]);

});

describe("->children()", function () {
Expand Down
8 changes: 5 additions & 3 deletions src/Reporter/Coverage/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ public function export($file = null)
}
$result = [];
$base = preg_quote($this->base(), '~');
foreach ($this->_coverage as $file => $coverage) {
$result[preg_replace("~^{$base}~", '', $file)] = $this->_coverage($file, $coverage);
foreach ($this->_coverage as $file => $rawCoverage) {
if ($coverage = $this->_coverage($file, $rawCoverage)) {
$result[preg_replace("~^{$base}~", '', $file)] = $coverage;
}
}
return $result;
}
Expand All @@ -316,7 +318,7 @@ public function export($file = null)
public function metrics()
{
$this->_metrics = new Metrics();
foreach ($this->_coverage as $file => $xdebug) {
foreach ($this->_coverage as $file => $rawCoverage) {
$root = $this->parse($file);
$coverage = $this->export($file);
$this->_processed = [
Expand Down

0 comments on commit c7411ec

Please sign in to comment.