Skip to content

Commit c17138a

Browse files
author
BackEndTea
committed
Add option to ignore covers annotation
1 parent 6f71fc1 commit c17138a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/CodeCoverage.php

+14
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ final class CodeCoverage
5656
*/
5757
private $forceCoversAnnotation = false;
5858

59+
/**
60+
* @var bool
61+
*/
62+
private $ignoreCoversAnnotation = false;
63+
5964
/**
6065
* @var bool
6166
*/
@@ -417,6 +422,11 @@ public function setForceCoversAnnotation(bool $flag): void
417422
$this->forceCoversAnnotation = $flag;
418423
}
419424

425+
public function setIgnoreCoversAnnotation(bool $flag): void
426+
{
427+
$this->ignoreCoversAnnotation = $flag;
428+
}
429+
420430
public function setCheckForMissingCoversAnnotation(bool $flag): void
421431
{
422432
$this->checkForMissingCoversAnnotation = $flag;
@@ -464,6 +474,10 @@ public function setUnintentionallyCoveredSubclassesWhitelist(array $whitelist):
464474
*/
465475
private function applyCoversAnnotationFilter(array &$data, $linesToBeCovered, array $linesToBeUsed, bool $ignoreForceCoversAnnotation): void
466476
{
477+
if ($this->ignoreCoversAnnotation) {
478+
return;
479+
}
480+
467481
if ($linesToBeCovered === false ||
468482
($this->forceCoversAnnotation && empty($linesToBeCovered) && !$ignoreForceCoversAnnotation)) {
469483
if ($this->checkForMissingCoversAnnotation) {

tests/tests/CodeCoverageTest.php

+11
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ public function testSetForceCoversAnnotation()
157157
);
158158
}
159159

160+
public function testIgnoreCoversAnnotation()
161+
{
162+
$this->coverage->setIgnoreCoversAnnotation(true);
163+
164+
$this->assertAttributeEquals(
165+
true,
166+
'ignoreCoversAnnotation',
167+
$this->coverage
168+
);
169+
}
170+
160171
public function testSetCheckForUnexecutedCoveredCode()
161172
{
162173
$this->coverage->setCheckForUnexecutedCoveredCode(true);

0 commit comments

Comments
 (0)