Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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