Skip to content

Commit 71a75f9

Browse files
Implement options for controlling whether details on PHPUnit deprecations should be displayed
1 parent 6f4ace4 commit 71a75f9

21 files changed

+90
-5
lines changed

ChangeLog-10.5.md

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

99
* [#5937](https://github.com/sebastianbergmann/phpunit/issues/5937): `failOnPhpunitDeprecation` attribute on the `<phpunit>` element of the XML configuration file and `--fail-on-phpunit-deprecation` CLI option for controlling whether PHPUnit deprecations should be considered when determining the test runner's shell exit code (default: do not consider)
10+
* `displayDetailsOnPhpunitDeprecations` attribute on the `<phpunit>` element of the XML configuration file and `--display-phpunit-deprecations` CLI option for controlling whether details on PHPUnit deprecations should be displayed (default: do not display)
1011

1112
## [10.5.31] - 2024-09-03
1213

phpunit.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@
214214
<xs:attribute name="displayDetailsOnIncompleteTests" type="xs:boolean" default="false"/>
215215
<xs:attribute name="displayDetailsOnSkippedTests" type="xs:boolean" default="false"/>
216216
<xs:attribute name="displayDetailsOnTestsThatTriggerDeprecations" type="xs:boolean" default="false"/>
217+
<xs:attribute name="displayDetailsOnPhpunitDeprecations" type="xs:boolean" default="false"/>
217218
<xs:attribute name="displayDetailsOnTestsThatTriggerErrors" type="xs:boolean" default="false"/>
218219
<xs:attribute name="displayDetailsOnTestsThatTriggerNotices" type="xs:boolean" default="false"/>
219220
<xs:attribute name="displayDetailsOnTestsThatTriggerWarnings" type="xs:boolean" default="false"/>

src/TextUI/Configuration/Cli/Builder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ final class Builder
5858
'display-incomplete',
5959
'display-skipped',
6060
'display-deprecations',
61+
'display-phpunit-deprecations',
6162
'display-errors',
6263
'display-notices',
6364
'display-warnings',
@@ -189,6 +190,7 @@ public function fromParameters(array $parameters): Configuration
189190
$displayIncomplete = null;
190191
$displaySkipped = null;
191192
$displayDeprecations = null;
193+
$displayPhpunitDeprecations = null;
192194
$displayErrors = null;
193195
$displayNotices = null;
194196
$displayWarnings = null;
@@ -766,6 +768,11 @@ public function fromParameters(array $parameters): Configuration
766768

767769
break;
768770

771+
case '--display-phpunit-deprecations':
772+
$displayPhpunitDeprecations = true;
773+
774+
break;
775+
769776
case '--display-errors':
770777
$displayErrors = true;
771778

@@ -974,6 +981,7 @@ public function fromParameters(array $parameters): Configuration
974981
$displayIncomplete,
975982
$displaySkipped,
976983
$displayDeprecations,
984+
$displayPhpunitDeprecations,
977985
$displayErrors,
978986
$displayNotices,
979987
$displayWarnings,

src/TextUI/Configuration/Cli/Configuration.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ final class Configuration
117117
private readonly ?bool $displayDetailsOnIncompleteTests;
118118
private readonly ?bool $displayDetailsOnSkippedTests;
119119
private readonly ?bool $displayDetailsOnTestsThatTriggerDeprecations;
120+
private readonly ?bool $displayDetailsOnPhpunitDeprecations;
120121
private readonly ?bool $displayDetailsOnTestsThatTriggerErrors;
121122
private readonly ?bool $displayDetailsOnTestsThatTriggerNotices;
122123
private readonly ?bool $displayDetailsOnTestsThatTriggerWarnings;
@@ -129,7 +130,7 @@ final class Configuration
129130
* @psalm-param list<non-empty-string> $arguments
130131
* @psalm-param ?non-empty-list<non-empty-string> $testSuffixes
131132
*/
132-
public function __construct(array $arguments, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, ?string $cacheResultFile, bool $checkVersion, ?string $colors, null|int|string $columns, ?string $configurationFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, ?string $coverageCacheDirectory, bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnDeprecation, ?bool $failOnPhpunitDeprecation, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $stopOnDefect, ?bool $stopOnDeprecation, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnNotice, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $filter, ?string $generateBaseline, ?string $useBaseline, bool $ignoreBaseline, bool $generateConfiguration, bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, bool $listGroups, bool $listSuites, bool $listTests, ?string $listTestsXml, ?bool $noCoverage, ?bool $noExtensions, ?bool $noOutput, ?bool $noProgress, ?bool $noResults, ?bool $noLogging, ?bool $processIsolation, ?int $randomOrderSeed, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, bool $useDefaultConfiguration, ?bool $displayDetailsOnIncompleteTests, ?bool $displayDetailsOnSkippedTests, ?bool $displayDetailsOnTestsThatTriggerDeprecations, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $printerTestDox, bool $debug)
133+
public function __construct(array $arguments, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, ?string $cacheResultFile, bool $checkVersion, ?string $colors, null|int|string $columns, ?string $configurationFile, ?string $coverageClover, ?string $coverageCobertura, ?string $coverageCrap4J, ?string $coverageHtml, ?string $coveragePhp, ?string $coverageText, ?bool $coverageTextShowUncoveredFiles, ?bool $coverageTextShowOnlySummary, ?string $coverageXml, ?bool $pathCoverage, ?string $coverageCacheDirectory, bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnDeprecation, ?bool $failOnPhpunitDeprecation, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $stopOnDefect, ?bool $stopOnDeprecation, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnNotice, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $filter, ?string $generateBaseline, ?string $useBaseline, bool $ignoreBaseline, bool $generateConfiguration, bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, bool $listGroups, bool $listSuites, bool $listTests, ?string $listTestsXml, ?bool $noCoverage, ?bool $noExtensions, ?bool $noOutput, ?bool $noProgress, ?bool $noResults, ?bool $noLogging, ?bool $processIsolation, ?int $randomOrderSeed, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, bool $useDefaultConfiguration, ?bool $displayDetailsOnIncompleteTests, ?bool $displayDetailsOnSkippedTests, ?bool $displayDetailsOnTestsThatTriggerDeprecations, ?bool $displayDetailsOnPhpunitDeprecations, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $printerTestDox, bool $debug)
133134
{
134135
$this->arguments = $arguments;
135136
$this->atLeastVersion = $atLeastVersion;
@@ -221,6 +222,7 @@ public function __construct(array $arguments, ?string $atLeastVersion, ?bool $ba
221222
$this->displayDetailsOnIncompleteTests = $displayDetailsOnIncompleteTests;
222223
$this->displayDetailsOnSkippedTests = $displayDetailsOnSkippedTests;
223224
$this->displayDetailsOnTestsThatTriggerDeprecations = $displayDetailsOnTestsThatTriggerDeprecations;
225+
$this->displayDetailsOnPhpunitDeprecations = $displayDetailsOnPhpunitDeprecations;
224226
$this->displayDetailsOnTestsThatTriggerErrors = $displayDetailsOnTestsThatTriggerErrors;
225227
$this->displayDetailsOnTestsThatTriggerNotices = $displayDetailsOnTestsThatTriggerNotices;
226228
$this->displayDetailsOnTestsThatTriggerWarnings = $displayDetailsOnTestsThatTriggerWarnings;
@@ -1920,6 +1922,26 @@ public function displayDetailsOnTestsThatTriggerDeprecations(): bool
19201922
return $this->displayDetailsOnTestsThatTriggerDeprecations;
19211923
}
19221924

1925+
/**
1926+
* @psalm-assert-if-true !null $this->displayDetailsOnPhpunitDeprecations
1927+
*/
1928+
public function hasDisplayDetailsOnPhpunitDeprecations(): bool
1929+
{
1930+
return $this->displayDetailsOnPhpunitDeprecations !== null;
1931+
}
1932+
1933+
/**
1934+
* @throws Exception
1935+
*/
1936+
public function displayDetailsOnPhpunitDeprecations(): bool
1937+
{
1938+
if (!$this->hasDisplayDetailsOnPhpunitDeprecations()) {
1939+
throw new Exception;
1940+
}
1941+
1942+
return $this->displayDetailsOnPhpunitDeprecations;
1943+
}
1944+
19231945
/**
19241946
* @psalm-assert-if-true !null $this->displayDetailsOnTestsThatTriggerErrors
19251947
*/

src/TextUI/Configuration/Configuration.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ final class Configuration
9999
private readonly bool $displayDetailsOnIncompleteTests;
100100
private readonly bool $displayDetailsOnSkippedTests;
101101
private readonly bool $displayDetailsOnTestsThatTriggerDeprecations;
102+
private readonly bool $displayDetailsOnPhpunitDeprecations;
102103
private readonly bool $displayDetailsOnTestsThatTriggerErrors;
103104
private readonly bool $displayDetailsOnTestsThatTriggerNotices;
104105
private readonly bool $displayDetailsOnTestsThatTriggerWarnings;
@@ -147,7 +148,7 @@ final class Configuration
147148
* @psalm-param non-empty-list<non-empty-string> $testSuffixes
148149
* @psalm-param list<array{className: class-string, parameters: array<string, string>}> $extensionBootstrappers
149150
*/
150-
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, bool $stopOnError, bool $stopOnFailure, bool $stopOnIncomplete, bool $stopOnNotice, bool $stopOnRisky, bool $stopOnSkipped, bool $stopOnWarning, bool $outputToStandardErrorStream, int|string $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 $displayDetailsOnTestsThatTriggerErrors, bool $displayDetailsOnTestsThatTriggerNotices, bool $displayDetailsOnTestsThatTriggerWarnings, bool $reverseDefectList, bool $requireCoverageMetadata, bool $registerMockObjectsFromTestArgumentsRecursively, 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, ?array $testsCovering, ?array $testsUsing, ?string $filter, ?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)
151+
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, bool $stopOnError, bool $stopOnFailure, bool $stopOnIncomplete, bool $stopOnNotice, bool $stopOnRisky, bool $stopOnSkipped, bool $stopOnWarning, bool $outputToStandardErrorStream, int|string $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 $registerMockObjectsFromTestArgumentsRecursively, 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, ?array $testsCovering, ?array $testsUsing, ?string $filter, ?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)
151152
{
152153
$this->cliArguments = $cliArguments;
153154
$this->configurationFile = $configurationFile;
@@ -216,6 +217,7 @@ public function __construct(array $cliArguments, ?string $configurationFile, ?st
216217
$this->displayDetailsOnIncompleteTests = $displayDetailsOnIncompleteTests;
217218
$this->displayDetailsOnSkippedTests = $displayDetailsOnSkippedTests;
218219
$this->displayDetailsOnTestsThatTriggerDeprecations = $displayDetailsOnTestsThatTriggerDeprecations;
220+
$this->displayDetailsOnPhpunitDeprecations = $displayDetailsOnPhpunitDeprecations;
219221
$this->displayDetailsOnTestsThatTriggerErrors = $displayDetailsOnTestsThatTriggerErrors;
220222
$this->displayDetailsOnTestsThatTriggerNotices = $displayDetailsOnTestsThatTriggerNotices;
221223
$this->displayDetailsOnTestsThatTriggerWarnings = $displayDetailsOnTestsThatTriggerWarnings;
@@ -910,6 +912,11 @@ public function displayDetailsOnTestsThatTriggerDeprecations(): bool
910912
return $this->displayDetailsOnTestsThatTriggerDeprecations;
911913
}
912914

915+
public function displayDetailsOnPhpunitDeprecations(): bool
916+
{
917+
return $this->displayDetailsOnPhpunitDeprecations;
918+
}
919+
913920
public function displayDetailsOnTestsThatTriggerErrors(): bool
914921
{
915922
return $this->displayDetailsOnTestsThatTriggerErrors;

src/TextUI/Configuration/Merger.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,12 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
456456
$displayDetailsOnTestsThatTriggerDeprecations = $xmlConfiguration->phpunit()->displayDetailsOnTestsThatTriggerDeprecations();
457457
}
458458

459+
if ($cliConfiguration->hasDisplayDetailsOnPhpunitDeprecations()) {
460+
$displayDetailsOnPhpunitDeprecations = $cliConfiguration->displayDetailsOnPhpunitDeprecations();
461+
} else {
462+
$displayDetailsOnPhpunitDeprecations = $xmlConfiguration->phpunit()->displayDetailsOnPhpunitDeprecations();
463+
}
464+
459465
if ($cliConfiguration->hasDisplayDetailsOnTestsThatTriggerErrors()) {
460466
$displayDetailsOnTestsThatTriggerErrors = $cliConfiguration->displayDetailsOnTestsThatTriggerErrors();
461467
} else {
@@ -818,6 +824,7 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
818824
$displayDetailsOnIncompleteTests,
819825
$displayDetailsOnSkippedTests,
820826
$displayDetailsOnTestsThatTriggerDeprecations,
827+
$displayDetailsOnPhpunitDeprecations,
821828
$displayDetailsOnTestsThatTriggerErrors,
822829
$displayDetailsOnTestsThatTriggerNotices,
823830
$displayDetailsOnTestsThatTriggerWarnings,

src/TextUI/Configuration/Xml/DefaultConfiguration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ public static function create(): self
111111
false,
112112
false,
113113
false,
114+
false,
114115
null,
115116
false,
116117
false,

src/TextUI/Configuration/Xml/Generator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ final class Generator
3131
requireCoverageMetadata="true"
3232
beStrictAboutCoverageMetadata="true"
3333
beStrictAboutOutputDuringTests="true"
34+
displayDetailsOnPhpunitDeprecations="true"
3435
failOnPhpunitDeprecation="true"
3536
failOnRisky="true"
3637
failOnWarning="true">

0 commit comments

Comments
 (0)