Skip to content

Commit

Permalink
Fix @coversNothing
Browse files Browse the repository at this point in the history
  • Loading branch information
edorian committed Oct 29, 2012
1 parent 52fe078 commit 9b99186
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions ChangeLog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PHP_CodeCoverage 1.2.7
----------------------

* The `html5shiv.js` is now bundled.
* Fixed sebastianbergmann/phpunit#702: `@coversNothing` didn't work as documented.

PHP_CodeCoverage 1.2.6
----------------------
Expand Down
6 changes: 5 additions & 1 deletion PHP/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,10 @@ protected function applyCoversAnnotationFilter(&$data, $id)
$linesToBeCovered = $this->getLinesToBeCovered(
$testClassName, $id->getName()
);
if($linesToBeCovered === false) {
$data = array();
return;
}

if ($this->mapTestClassNameToCoveredClassName &&
empty($linesToBeCovered)) {
Expand Down Expand Up @@ -611,7 +615,7 @@ protected function getLinesToBeCovered($className, $methodName)
}

if (strpos($docComment, '@coversNothing') !== FALSE) {
return $result;
return false;
}

$classShortcut = preg_match_all(
Expand Down
8 changes: 6 additions & 2 deletions Tests/PHP/CodeCoverageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,14 @@ public function testGetLinesToBeCovered($test, $lines)
);
}

else if ($test === 'CoverageNoneTest' || $test === 'CoverageNothingTest') {
else if ($test === 'CoverageNoneTest') {
$expected = array();
}

else if ($test === 'CoverageNothingTest') {
$expected = false;
}

else if ($test === 'CoverageFunctionTest') {
$expected = array(
TEST_FILES_PATH . 'CoveredFunction.php' => $lines
Expand Down Expand Up @@ -492,7 +496,7 @@ public function getLinesToBeCoveredProvider()
),
array(
'CoverageNothingTest',
array()
false
)
);
}
Expand Down

0 comments on commit 9b99186

Please sign in to comment.