Skip to content

Commit c80daf0

Browse files
Merge branch '10.5' into 11.5
2 parents 505ed63 + c4fa2c3 commit c80daf0

File tree

55 files changed

+330
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+330
-76
lines changed

ChangeLog-11.5.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ All notable changes of the PHPUnit 11.5 release series are documented in this fi
66

77
### Added
88

9-
* [#6239](https://github.com/sebastianbergmann/phpunit/issues/6239): `--do-not-fail-on-deprecation`, `--do-not-fail-on-phpunit-deprecation`, `--do-not-fail-on-empty-test-suite`, `--do-not-fail-on-incomplete`, `--do-not-fail-on-notice`, `--do-not-fail-on-risky`, `--do-not-fail-on-skipped`, and `--do-not-fail-on-warning` CLI options
9+
* [#6236](https://github.com/sebastianbergmann/phpunit/issues/6236): `failOnPhpunitWarning` attribute on the `<phpunit>` element of the XML configuration file and `--fail-on-phpunit-warning` CLI option for controlling whether PHPUnit should fail on PHPUnit warnings (default: `true`)
10+
* [#6239](https://github.com/sebastianbergmann/phpunit/issues/6239): `--do-not-fail-on-deprecation`, `--do-not-fail-on-phpunit-warning`, --do-not-fail-on-phpunit-deprecation`, `--do-not-fail-on-empty-test-suite`, `--do-not-fail-on-incomplete`, `--do-not-fail-on-notice`, `--do-not-fail-on-risky`, `--do-not-fail-on-skipped`, and `--do-not-fail-on-warning` CLI options
1011
* `--do-not-report-useless-tests` CLI option as a replacement for `--dont-report-useless-tests`
1112

1213
### Deprecated

phpunit.xsd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@
181181
<xs:attribute name="failOnAllIssues" type="xs:boolean" default="false"/>
182182
<xs:attribute name="failOnDeprecation" type="xs:boolean" default="false"/>
183183
<xs:attribute name="failOnPhpunitDeprecation" type="xs:boolean" default="false"/>
184+
<xs:attribute name="failOnPhpunitWarning" type="xs:boolean" default="true"/>
184185
<xs:attribute name="failOnEmptyTestSuite" type="xs:boolean" default="false"/>
185186
<xs:attribute name="failOnIncomplete" type="xs:boolean" default="false"/>
186187
<xs:attribute name="failOnNotice" type="xs:boolean" default="false"/>

src/Runner/TestResult/TestResult.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -387,14 +387,6 @@ public function hasTestRunnerTriggeredWarningEvents(): bool
387387
}
388388

389389
public function wasSuccessful(): bool
390-
{
391-
return $this->wasSuccessfulIgnoringPhpunitWarnings() &&
392-
!$this->hasTestTriggeredPhpunitErrorEvents() &&
393-
!$this->hasTestRunnerTriggeredWarningEvents() &&
394-
!$this->hasTestTriggeredPhpunitWarningEvents();
395-
}
396-
397-
public function wasSuccessfulIgnoringPhpunitWarnings(): bool
398390
{
399391
return !$this->hasTestErroredEvents() &&
400392
!$this->hasTestFailedEvents() &&
@@ -414,7 +406,8 @@ public function hasTestsWithIssues(): bool
414406
$this->hasDeprecations() ||
415407
!empty($this->errors) ||
416408
$this->hasNotices() ||
417-
$this->hasWarnings();
409+
$this->hasWarnings() ||
410+
$this->hasPhpunitWarnings();
418411
}
419412

420413
/**
@@ -517,6 +510,17 @@ public function numberOfPhpunitDeprecations(): int
517510
count($this->testRunnerTriggeredDeprecationEvents);
518511
}
519512

513+
public function hasPhpunitWarnings(): bool
514+
{
515+
return $this->numberOfPhpunitWarnings() > 0;
516+
}
517+
518+
public function numberOfPhpunitWarnings(): int
519+
{
520+
return count($this->testTriggeredPhpunitWarningEvents) +
521+
count($this->testRunnerTriggeredWarningEvents);
522+
}
523+
520524
public function numberOfDeprecations(): int
521525
{
522526
return count($this->deprecations) +
@@ -544,9 +548,7 @@ public function hasWarnings(): bool
544548
public function numberOfWarnings(): int
545549
{
546550
return count($this->warnings) +
547-
count($this->phpWarnings) +
548-
count($this->testTriggeredPhpunitWarningEvents) +
549-
count($this->testRunnerTriggeredWarningEvents);
551+
count($this->phpWarnings);
550552
}
551553

552554
public function hasIncompleteTests(): bool

src/TextUI/Configuration/Cli/Builder.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ final class Builder
111111
'fail-on-all-issues',
112112
'fail-on-deprecation',
113113
'fail-on-phpunit-deprecation',
114+
'fail-on-phpunit-warning',
114115
'fail-on-empty-test-suite',
115116
'fail-on-incomplete',
116117
'fail-on-notice',
@@ -119,6 +120,7 @@ final class Builder
119120
'fail-on-warning',
120121
'do-not-fail-on-deprecation',
121122
'do-not-fail-on-phpunit-deprecation',
123+
'do-not-fail-on-phpunit-warning',
122124
'do-not-fail-on-empty-test-suite',
123125
'do-not-fail-on-incomplete',
124126
'do-not-fail-on-notice',
@@ -220,6 +222,7 @@ public function fromParameters(array $parameters): Configuration
220222
$failOnAllIssues = null;
221223
$failOnDeprecation = null;
222224
$failOnPhpunitDeprecation = null;
225+
$failOnPhpunitWarning = null;
223226
$failOnEmptyTestSuite = null;
224227
$failOnIncomplete = null;
225228
$failOnNotice = null;
@@ -228,6 +231,7 @@ public function fromParameters(array $parameters): Configuration
228231
$failOnWarning = null;
229232
$doNotFailOnDeprecation = null;
230233
$doNotFailOnPhpunitDeprecation = null;
234+
$doNotFailOnPhpunitWarning = null;
231235
$doNotFailOnEmptyTestSuite = null;
232236
$doNotFailOnIncomplete = null;
233237
$doNotFailOnNotice = null;
@@ -704,6 +708,17 @@ public function fromParameters(array $parameters): Configuration
704708

705709
break;
706710

711+
case '--fail-on-phpunit-warning':
712+
$this->warnWhenOptionsConflict(
713+
$doNotFailOnPhpunitWarning,
714+
'--fail-on-phpunit-warning',
715+
'--do-not-fail-on-phpunit-warning',
716+
);
717+
718+
$failOnPhpunitWarning = true;
719+
720+
break;
721+
707722
case '--fail-on-empty-test-suite':
708723
$this->warnWhenOptionsConflict(
709724
$doNotFailOnEmptyTestSuite,
@@ -792,6 +807,17 @@ public function fromParameters(array $parameters): Configuration
792807

793808
break;
794809

810+
case '--do-not-fail-on-phpunit-warning':
811+
$this->warnWhenOptionsConflict(
812+
$failOnPhpunitWarning,
813+
'--do-not-fail-on-phpunit-warning',
814+
'--fail-on-phpunit-warning',
815+
);
816+
817+
$doNotFailOnPhpunitWarning = true;
818+
819+
break;
820+
795821
case '--do-not-fail-on-empty-test-suite':
796822
$this->warnWhenOptionsConflict(
797823
$failOnEmptyTestSuite,
@@ -1201,6 +1227,7 @@ public function fromParameters(array $parameters): Configuration
12011227
$failOnAllIssues,
12021228
$failOnDeprecation,
12031229
$failOnPhpunitDeprecation,
1230+
$failOnPhpunitWarning,
12041231
$failOnEmptyTestSuite,
12051232
$failOnIncomplete,
12061233
$failOnNotice,
@@ -1209,6 +1236,7 @@ public function fromParameters(array $parameters): Configuration
12091236
$failOnWarning,
12101237
$doNotFailOnDeprecation,
12111238
$doNotFailOnPhpunitDeprecation,
1239+
$doNotFailOnPhpunitWarning,
12121240
$doNotFailOnEmptyTestSuite,
12131241
$doNotFailOnIncomplete,
12141242
$doNotFailOnNotice,

src/TextUI/Configuration/Cli/Configuration.php

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
private ?bool $failOnAllIssues;
6464
private ?bool $failOnDeprecation;
6565
private ?bool $failOnPhpunitDeprecation;
66+
private ?bool $failOnPhpunitWarning;
6667
private ?bool $failOnEmptyTestSuite;
6768
private ?bool $failOnIncomplete;
6869
private ?bool $failOnNotice;
@@ -71,6 +72,7 @@
7172
private ?bool $failOnWarning;
7273
private ?bool $doNotFailOnDeprecation;
7374
private ?bool $doNotFailOnPhpunitDeprecation;
75+
private ?bool $doNotFailOnPhpunitWarning;
7476
private ?bool $doNotFailOnEmptyTestSuite;
7577
private ?bool $doNotFailOnIncomplete;
7678
private ?bool $doNotFailOnNotice;
@@ -184,7 +186,7 @@
184186
* @param ?non-empty-list<non-empty-string> $coverageFilter
185187
* @param ?non-empty-list<non-empty-string> $extensions
186188
*/
187-
public function __construct(array $arguments, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, 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, bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnAllIssues, ?bool $failOnDeprecation, ?bool $failOnPhpunitDeprecation, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $doNotFailOnDeprecation, ?bool $doNotFailOnPhpunitDeprecation, ?bool $doNotFailOnEmptyTestSuite, ?bool $doNotFailOnIncomplete, ?bool $doNotFailOnNotice, ?bool $doNotFailOnRisky, ?bool $doNotFailOnSkipped, ?bool $doNotFailOnWarning, ?bool $stopOnDefect, ?bool $stopOnDeprecation, ?string $specificDeprecationToStopOn, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnNotice, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $filter, ?string $excludeFilter, ?string $generateBaseline, ?string $useBaseline, bool $ignoreBaseline, bool $generateConfiguration, bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, ?array $testsRequiringPhpExtension, bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, bool $listGroups, bool $listSuites, bool $listTestFiles, 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 $displayDetailsOnAllIssues, ?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 $testdoxPrinter, ?bool $testdoxPrinterSummary, bool $debug, ?array $extensions)
189+
public function __construct(array $arguments, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, 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, bool $warmCoverageCache, ?int $defaultTimeLimit, ?bool $disableCodeCoverageIgnore, ?bool $disallowTestOutput, ?bool $enforceTimeLimit, ?array $excludeGroups, ?int $executionOrder, ?int $executionOrderDefects, ?bool $failOnAllIssues, ?bool $failOnDeprecation, ?bool $failOnPhpunitDeprecation, ?bool $failOnPhpunitWarning, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $doNotFailOnDeprecation, ?bool $doNotFailOnPhpunitDeprecation, ?bool $doNotFailOnPhpunitWarning, ?bool $doNotFailOnEmptyTestSuite, ?bool $doNotFailOnIncomplete, ?bool $doNotFailOnNotice, ?bool $doNotFailOnRisky, ?bool $doNotFailOnSkipped, ?bool $doNotFailOnWarning, ?bool $stopOnDefect, ?bool $stopOnDeprecation, ?string $specificDeprecationToStopOn, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnNotice, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $filter, ?string $excludeFilter, ?string $generateBaseline, ?string $useBaseline, bool $ignoreBaseline, bool $generateConfiguration, bool $migrateConfiguration, ?array $groups, ?array $testsCovering, ?array $testsUsing, ?array $testsRequiringPhpExtension, bool $help, ?string $includePath, ?array $iniSettings, ?string $junitLogfile, bool $listGroups, bool $listSuites, bool $listTestFiles, 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 $displayDetailsOnAllIssues, ?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 $testdoxPrinter, ?bool $testdoxPrinterSummary, bool $debug, ?array $extensions)
188190
{
189191
$this->arguments = $arguments;
190192
$this->atLeastVersion = $atLeastVersion;
@@ -220,6 +222,7 @@ public function __construct(array $arguments, ?string $atLeastVersion, ?bool $ba
220222
$this->failOnAllIssues = $failOnAllIssues;
221223
$this->failOnDeprecation = $failOnDeprecation;
222224
$this->failOnPhpunitDeprecation = $failOnPhpunitDeprecation;
225+
$this->failOnPhpunitWarning = $failOnPhpunitWarning;
223226
$this->failOnEmptyTestSuite = $failOnEmptyTestSuite;
224227
$this->failOnIncomplete = $failOnIncomplete;
225228
$this->failOnNotice = $failOnNotice;
@@ -228,6 +231,7 @@ public function __construct(array $arguments, ?string $atLeastVersion, ?bool $ba
228231
$this->failOnWarning = $failOnWarning;
229232
$this->doNotFailOnDeprecation = $doNotFailOnDeprecation;
230233
$this->doNotFailOnPhpunitDeprecation = $doNotFailOnPhpunitDeprecation;
234+
$this->doNotFailOnPhpunitWarning = $doNotFailOnPhpunitWarning;
231235
$this->doNotFailOnEmptyTestSuite = $doNotFailOnEmptyTestSuite;
232236
$this->doNotFailOnIncomplete = $doNotFailOnIncomplete;
233237
$this->doNotFailOnNotice = $doNotFailOnNotice;
@@ -944,6 +948,26 @@ public function failOnPhpunitDeprecation(): bool
944948
return $this->failOnPhpunitDeprecation;
945949
}
946950

951+
/**
952+
* @phpstan-assert-if-true !null $this->failOnPhpunitWarning
953+
*/
954+
public function hasFailOnPhpunitWarning(): bool
955+
{
956+
return $this->failOnPhpunitWarning !== null;
957+
}
958+
959+
/**
960+
* @throws Exception
961+
*/
962+
public function failOnPhpunitWarning(): bool
963+
{
964+
if (!$this->hasFailOnPhpunitWarning()) {
965+
throw new Exception;
966+
}
967+
968+
return $this->failOnPhpunitWarning;
969+
}
970+
947971
/**
948972
* @phpstan-assert-if-true !null $this->failOnEmptyTestSuite
949973
*/
@@ -1104,6 +1128,26 @@ public function doNotFailOnPhpunitDeprecation(): bool
11041128
return $this->doNotFailOnPhpunitDeprecation;
11051129
}
11061130

1131+
/**
1132+
* @phpstan-assert-if-true !null $this->doNotFailOnPhpunitWarning
1133+
*/
1134+
public function hasDoNotFailOnPhpunitWarning(): bool
1135+
{
1136+
return $this->doNotFailOnPhpunitWarning !== null;
1137+
}
1138+
1139+
/**
1140+
* @throws Exception
1141+
*/
1142+
public function doNotFailOnPhpunitWarning(): bool
1143+
{
1144+
if (!$this->hasDoNotFailOnPhpunitWarning()) {
1145+
throw new Exception;
1146+
}
1147+
1148+
return $this->doNotFailOnPhpunitWarning;
1149+
}
1150+
11071151
/**
11081152
* @phpstan-assert-if-true !null $this->doNotFailOnEmptyTestSuite
11091153
*/

0 commit comments

Comments
 (0)