Skip to content

Commit

Permalink
Add option to ignore covers annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
BackEndTea committed Jan 5, 2018
1 parent 6f71fc1 commit be5c988
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/CodeCoverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ final class CodeCoverage
*/
private $forceCoversAnnotation = false;

/**
* @var bool
*/
private $ignoreCoversAnnotation = false;

/**
* @var bool
*/
Expand Down Expand Up @@ -417,6 +422,11 @@ public function setForceCoversAnnotation(bool $flag): void
$this->forceCoversAnnotation = $flag;
}

public function setIgnoreCoversAnnotation(bool $flag): void
{
$this->ignoreCoversAnnotation = $flag;
}

public function setCheckForMissingCoversAnnotation(bool $flag): void
{
$this->checkForMissingCoversAnnotation = $flag;
Expand Down Expand Up @@ -464,6 +474,10 @@ public function setUnintentionallyCoveredSubclassesWhitelist(array $whitelist):
*/
private function applyCoversAnnotationFilter(array &$data, $linesToBeCovered, array $linesToBeUsed, bool $ignoreForceCoversAnnotation): void
{
if ($this->ignoreCoversAnnotation) {
return;
}

if ($linesToBeCovered === false ||
($this->forceCoversAnnotation && empty($linesToBeCovered) && !$ignoreForceCoversAnnotation)) {
if ($this->checkForMissingCoversAnnotation) {
Expand Down
11 changes: 11 additions & 0 deletions tests/tests/CodeCoverageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ public function testSetForceCoversAnnotation()
);
}

public function testIgnoreCoversAnnotation()
{
$this->coverage->setIgnoreCoversAnnotation(true);

$this->assertAttributeEquals(
true,
'ignoreCoversAnnotation',
$this->coverage
);
}

public function testSetCheckForUnexecutedCoveredCode()
{
$this->coverage->setCheckForUnexecutedCoveredCode(true);
Expand Down

0 comments on commit be5c988

Please sign in to comment.