Skip to content

Commit e743ec6

Browse files
Revert "Closes #5952"
This reverts commit 1964ae3.
1 parent 18b9ed6 commit e743ec6

File tree

8 files changed

+36
-2
lines changed

8 files changed

+36
-2
lines changed

ChangeLog-12.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All notable changes of the PHPUnit 12.0 release series are documented in this fi
66

77
### Fixed
88

9+
* [#5951](https://github.com/sebastianbergmann/phpunit/issues/5951#issuecomment-2656364815): Restore the `includeUncoveredFiles` configuration option
910
* A `Test\Passed` event is no longer emitted in addition to a `Test\Failed` or `Test\Errored` event when an assertion failure or an unexpected exception is triggered in an after-test method
1011
* A `TestSuite\Finished` event is now emitted when a before-first-test method errors
1112

src/Runner/CodeCoverage.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ public function init(Configuration $configuration, CodeCoverageFilterRegistry $c
100100
$this->codeCoverage()->enableAnnotationsForIgnoringCode();
101101
}
102102

103+
if ($configuration->includeUncoveredFiles()) {
104+
$this->codeCoverage()->includeUncoveredFiles();
105+
} else {
106+
$this->codeCoverage()->excludeUncoveredFiles();
107+
}
108+
103109
if ($codeCoverageFilterRegistry->get()->isEmpty()) {
104110
if (!$codeCoverageFilterRegistry->configured()) {
105111
EventFacade::emitter()->testRunnerTriggeredWarning(

src/TextUI/Configuration/Configuration.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
*/
150150
private array $excludeGroups;
151151
private int $randomOrderSeed;
152+
private bool $includeUncoveredFiles;
152153
private TestSuiteCollection $testSuite;
153154
private string $includeTestSuite;
154155
private string $excludeTestSuite;
@@ -186,7 +187,7 @@
186187
* @param null|non-empty-string $generateBaseline
187188
* @param non-negative-int $shortenArraysForExportThreshold
188189
*/
189-
public function __construct(array $cliArguments, ?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, Source $source, string $testResultCacheFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4j, int $coverageCrap4jThreshold, ?string $coverageHtml, int $coverageHtmlLowUpperBound, int $coverageHtmlHighLowerBound, string $coverageHtmlColorSuccessLow, string $coverageHtmlColorSuccessMedium, string $coverageHtmlColorSuccessHigh, string $coverageHtmlColorWarning, string $coverageHtmlColorDanger, ?string $coverageHtmlCustomCssFile, ?string $coveragePhp, ?string $coverageText, bool $coverageTextShowUncoveredFiles, bool $coverageTextShowOnlySummary, ?string $coverageXml, bool $pathCoverage, bool $ignoreDeprecatedCodeUnitsFromCodeCoverage, bool $disableCodeCoverageIgnore, bool $failOnDeprecation, bool $failOnPhpunitDeprecation, bool $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnNotice, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $stopOnDefect, bool $stopOnDeprecation, ?string $specificDeprecationToStopOn, bool $stopOnError, bool $stopOnFailure, bool $stopOnIncomplete, bool $stopOnNotice, bool $stopOnRisky, bool $stopOnSkipped, bool $stopOnWarning, bool $outputToStandardErrorStream, int $columns, bool $noExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $enforceTimeLimit, int $defaultTimeLimit, int $timeoutForSmallTests, int $timeoutForMediumTests, int $timeoutForLargeTests, bool $reportUselessTests, bool $strictCoverage, bool $disallowTestOutput, bool $displayDetailsOnIncompleteTests, bool $displayDetailsOnSkippedTests, bool $displayDetailsOnTestsThatTriggerDeprecations, bool $displayDetailsOnPhpunitDeprecations, bool $displayDetailsOnTestsThatTriggerErrors, bool $displayDetailsOnTestsThatTriggerNotices, bool $displayDetailsOnTestsThatTriggerWarnings, bool $reverseDefectList, bool $requireCoverageMetadata, bool $noProgress, bool $noResults, bool $noOutput, int $executionOrder, int $executionOrderDefects, bool $resolveDependencies, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logEventsText, ?string $logEventsVerboseText, bool $teamCityOutput, bool $testDoxOutput, bool $testDoxOutputSummary, ?array $testsCovering, ?array $testsUsing, ?array $testsRequiringPhpExtension, ?string $filter, ?string $excludeFilter, array $groups, array $excludeGroups, int $randomOrderSeed, TestSuiteCollection $testSuite, string $includeTestSuite, string $excludeTestSuite, ?string $defaultTestSuite, array $testSuffixes, Php $php, bool $controlGarbageCollector, int $numberOfTestsBeforeGarbageCollection, ?string $generateBaseline, bool $debug, int $shortenArraysForExportThreshold)
190+
public function __construct(array $cliArguments, ?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, Source $source, string $testResultCacheFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4j, int $coverageCrap4jThreshold, ?string $coverageHtml, int $coverageHtmlLowUpperBound, int $coverageHtmlHighLowerBound, string $coverageHtmlColorSuccessLow, string $coverageHtmlColorSuccessMedium, string $coverageHtmlColorSuccessHigh, string $coverageHtmlColorWarning, string $coverageHtmlColorDanger, ?string $coverageHtmlCustomCssFile, ?string $coveragePhp, ?string $coverageText, bool $coverageTextShowUncoveredFiles, bool $coverageTextShowOnlySummary, ?string $coverageXml, bool $pathCoverage, bool $ignoreDeprecatedCodeUnitsFromCodeCoverage, bool $disableCodeCoverageIgnore, bool $failOnDeprecation, bool $failOnPhpunitDeprecation, bool $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnNotice, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $stopOnDefect, bool $stopOnDeprecation, ?string $specificDeprecationToStopOn, bool $stopOnError, bool $stopOnFailure, bool $stopOnIncomplete, bool $stopOnNotice, bool $stopOnRisky, bool $stopOnSkipped, bool $stopOnWarning, bool $outputToStandardErrorStream, int $columns, bool $noExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $enforceTimeLimit, int $defaultTimeLimit, int $timeoutForSmallTests, int $timeoutForMediumTests, int $timeoutForLargeTests, bool $reportUselessTests, bool $strictCoverage, bool $disallowTestOutput, bool $displayDetailsOnIncompleteTests, bool $displayDetailsOnSkippedTests, bool $displayDetailsOnTestsThatTriggerDeprecations, bool $displayDetailsOnPhpunitDeprecations, bool $displayDetailsOnTestsThatTriggerErrors, bool $displayDetailsOnTestsThatTriggerNotices, bool $displayDetailsOnTestsThatTriggerWarnings, bool $reverseDefectList, bool $requireCoverageMetadata, bool $noProgress, bool $noResults, bool $noOutput, int $executionOrder, int $executionOrderDefects, bool $resolveDependencies, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logEventsText, ?string $logEventsVerboseText, bool $teamCityOutput, bool $testDoxOutput, bool $testDoxOutputSummary, ?array $testsCovering, ?array $testsUsing, ?array $testsRequiringPhpExtension, ?string $filter, ?string $excludeFilter, array $groups, array $excludeGroups, int $randomOrderSeed, bool $includeUncoveredFiles, TestSuiteCollection $testSuite, string $includeTestSuite, string $excludeTestSuite, ?string $defaultTestSuite, array $testSuffixes, Php $php, bool $controlGarbageCollector, int $numberOfTestsBeforeGarbageCollection, ?string $generateBaseline, bool $debug, int $shortenArraysForExportThreshold)
190191
{
191192
$this->cliArguments = $cliArguments;
192193
$this->configurationFile = $configurationFile;
@@ -285,6 +286,7 @@ public function __construct(array $cliArguments, ?string $configurationFile, ?st
285286
$this->groups = $groups;
286287
$this->excludeGroups = $excludeGroups;
287288
$this->randomOrderSeed = $randomOrderSeed;
289+
$this->includeUncoveredFiles = $includeUncoveredFiles;
288290
$this->testSuite = $testSuite;
289291
$this->includeTestSuite = $includeTestSuite;
290292
$this->excludeTestSuite = $excludeTestSuite;
@@ -1225,6 +1227,11 @@ public function randomOrderSeed(): int
12251227
return $this->randomOrderSeed;
12261228
}
12271229

1230+
public function includeUncoveredFiles(): bool
1231+
{
1232+
return $this->includeUncoveredFiles;
1233+
}
1234+
12281235
public function testSuite(): TestSuiteCollection
12291236
{
12301237
return $this->testSuite;

src/TextUI/Configuration/Merger.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,8 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
671671
}
672672
}
673673

674+
$includeUncoveredFiles = $xmlConfiguration->codeCoverage()->includeUncoveredFiles();
675+
674676
$includePaths = [];
675677

676678
if ($cliConfiguration->hasIncludePath()) {
@@ -889,6 +891,7 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
889891
$groups,
890892
$excludeGroups,
891893
$randomOrderSeed,
894+
$includeUncoveredFiles,
892895
$xmlConfiguration->testSuite(),
893896
$includeTestSuite,
894897
$excludeTestSuite,

src/TextUI/Configuration/Xml/CodeCoverage/CodeCoverage.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
final readonly class CodeCoverage
2929
{
3030
private bool $pathCoverage;
31+
private bool $includeUncoveredFiles;
3132
private bool $ignoreDeprecatedCodeUnits;
3233
private bool $disableCodeCoverageIgnore;
3334
private ?Clover $clover;
@@ -38,9 +39,10 @@
3839
private ?Text $text;
3940
private ?Xml $xml;
4041

41-
public function __construct(bool $pathCoverage, bool $ignoreDeprecatedCodeUnits, bool $disableCodeCoverageIgnore, ?Clover $clover, ?Cobertura $cobertura, ?Crap4j $crap4j, ?Html $html, ?Php $php, ?Text $text, ?Xml $xml)
42+
public function __construct(bool $pathCoverage, bool $includeUncoveredFiles, bool $ignoreDeprecatedCodeUnits, bool $disableCodeCoverageIgnore, ?Clover $clover, ?Cobertura $cobertura, ?Crap4j $crap4j, ?Html $html, ?Php $php, ?Text $text, ?Xml $xml)
4243
{
4344
$this->pathCoverage = $pathCoverage;
45+
$this->includeUncoveredFiles = $includeUncoveredFiles;
4446
$this->ignoreDeprecatedCodeUnits = $ignoreDeprecatedCodeUnits;
4547
$this->disableCodeCoverageIgnore = $disableCodeCoverageIgnore;
4648
$this->clover = $clover;
@@ -57,6 +59,11 @@ public function pathCoverage(): bool
5759
return $this->pathCoverage;
5860
}
5961

62+
public function includeUncoveredFiles(): bool
63+
{
64+
return $this->includeUncoveredFiles;
65+
}
66+
6067
public function ignoreDeprecatedCodeUnits(): bool
6168
{
6269
return $this->ignoreDeprecatedCodeUnits;

src/TextUI/Configuration/Xml/DefaultConfiguration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public static function create(): self
6363
),
6464
new CodeCoverage(
6565
false,
66+
true,
6667
false,
6768
false,
6869
null,

src/TextUI/Configuration/Xml/Loader.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ private function source(string $filename, DOMXPath $xpath): Source
351351
private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage
352352
{
353353
$pathCoverage = false;
354+
$includeUncoveredFiles = true;
354355
$ignoreDeprecatedCodeUnits = false;
355356
$disableCodeCoverageIgnore = false;
356357

@@ -363,6 +364,12 @@ private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage
363364
false,
364365
);
365366

367+
$includeUncoveredFiles = $this->getBooleanAttribute(
368+
$element,
369+
'includeUncoveredFiles',
370+
true,
371+
);
372+
366373
$ignoreDeprecatedCodeUnits = $this->getBooleanAttribute(
367374
$element,
368375
'ignoreDeprecatedCodeUnits',
@@ -490,6 +497,7 @@ private function codeCoverage(string $filename, DOMXPath $xpath): CodeCoverage
490497

491498
return new CodeCoverage(
492499
$pathCoverage,
500+
$includeUncoveredFiles,
493501
$ignoreDeprecatedCodeUnits,
494502
$disableCodeCoverageIgnore,
495503
$clover,

tests/unit/TextUI/Configuration/Xml/LoaderTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public function testCodeCoverageConfigurationIsReadCorrectly(): void
186186
$codeCoverage = $this->configuration('configuration_codecoverage.xml')->codeCoverage();
187187

188188
$this->assertTrue($codeCoverage->pathCoverage());
189+
$this->assertTrue($codeCoverage->includeUncoveredFiles());
189190
$this->assertTrue($codeCoverage->ignoreDeprecatedCodeUnits());
190191
$this->assertTrue($codeCoverage->disableCodeCoverageIgnore());
191192

0 commit comments

Comments
 (0)