Skip to content

Commit 6779c3d

Browse files
Merge branch '11.5' into 12.2
2 parents 8d19045 + c80daf0 commit 6779c3d

File tree

67 files changed

+346
-92
lines changed

Some content is hidden

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

67 files changed

+346
-92
lines changed

ChangeLog-12.2.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 12.2 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-phpunit-notice`, `--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
@@ -182,6 +182,7 @@
182182
<xs:attribute name="failOnDeprecation" type="xs:boolean" default="false"/>
183183
<xs:attribute name="failOnPhpunitDeprecation" type="xs:boolean" default="false"/>
184184
<xs:attribute name="failOnPhpunitNotice" type="xs:boolean" default="false"/>
185+
<xs:attribute name="failOnPhpunitWarning" type="xs:boolean" default="true"/>
185186
<xs:attribute name="failOnEmptyTestSuite" type="xs:boolean" default="false"/>
186187
<xs:attribute name="failOnIncomplete" type="xs:boolean" default="false"/>
187188
<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
@@ -441,14 +441,6 @@ public function hasTestRunnerTriggeredWarningEvents(): bool
441441
}
442442

443443
public function wasSuccessful(): bool
444-
{
445-
return $this->wasSuccessfulIgnoringPhpunitWarnings() &&
446-
!$this->hasTestTriggeredPhpunitErrorEvents() &&
447-
!$this->hasTestRunnerTriggeredWarningEvents() &&
448-
!$this->hasTestTriggeredPhpunitWarningEvents();
449-
}
450-
451-
public function wasSuccessfulIgnoringPhpunitWarnings(): bool
452444
{
453445
return !$this->hasTestErroredEvents() &&
454446
!$this->hasTestFailedEvents() &&
@@ -469,7 +461,8 @@ public function hasTestsWithIssues(): bool
469461
$this->errors !== [] ||
470462
$this->hasNotices() ||
471463
$this->hasWarnings() ||
472-
$this->hasPhpunitNotices();
464+
$this->hasPhpunitNotices() ||
465+
$this->hasPhpunitWarnings();
473466
}
474467

475468
/**
@@ -572,6 +565,17 @@ public function numberOfPhpunitDeprecations(): int
572565
count($this->testRunnerTriggeredDeprecationEvents);
573566
}
574567

568+
public function hasPhpunitWarnings(): bool
569+
{
570+
return $this->numberOfPhpunitWarnings() > 0;
571+
}
572+
573+
public function numberOfPhpunitWarnings(): int
574+
{
575+
return count($this->testTriggeredPhpunitWarningEvents) +
576+
count($this->testRunnerTriggeredWarningEvents);
577+
}
578+
575579
public function numberOfDeprecations(): int
576580
{
577581
return count($this->deprecations) +
@@ -599,9 +603,7 @@ public function hasWarnings(): bool
599603
public function numberOfWarnings(): int
600604
{
601605
return count($this->warnings) +
602-
count($this->phpWarnings) +
603-
count($this->testTriggeredPhpunitWarningEvents) +
604-
count($this->testRunnerTriggeredWarningEvents);
606+
count($this->phpWarnings);
605607
}
606608

607609
public function hasIncompleteTests(): bool

src/TextUI/Configuration/Cli/Builder.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ final class Builder
115115
'fail-on-deprecation',
116116
'fail-on-phpunit-deprecation',
117117
'fail-on-phpunit-notice',
118+
'fail-on-phpunit-warning',
118119
'fail-on-empty-test-suite',
119120
'fail-on-incomplete',
120121
'fail-on-notice',
@@ -124,6 +125,7 @@ final class Builder
124125
'do-not-fail-on-deprecation',
125126
'do-not-fail-on-phpunit-deprecation',
126127
'do-not-fail-on-phpunit-notice',
128+
'do-not-fail-on-phpunit-warning',
127129
'do-not-fail-on-empty-test-suite',
128130
'do-not-fail-on-incomplete',
129131
'do-not-fail-on-notice',
@@ -230,6 +232,7 @@ public function fromParameters(array $parameters): Configuration
230232
$failOnDeprecation = null;
231233
$failOnPhpunitDeprecation = null;
232234
$failOnPhpunitNotice = null;
235+
$failOnPhpunitWarning = null;
233236
$failOnEmptyTestSuite = null;
234237
$failOnIncomplete = null;
235238
$failOnNotice = null;
@@ -239,6 +242,7 @@ public function fromParameters(array $parameters): Configuration
239242
$doNotFailOnDeprecation = null;
240243
$doNotFailOnPhpunitDeprecation = null;
241244
$doNotFailOnPhpunitNotice = null;
245+
$doNotFailOnPhpunitWarning = null;
242246
$doNotFailOnEmptyTestSuite = null;
243247
$doNotFailOnIncomplete = null;
244248
$doNotFailOnNotice = null;
@@ -712,6 +716,17 @@ public function fromParameters(array $parameters): Configuration
712716

713717
break;
714718

719+
case '--fail-on-phpunit-warning':
720+
$this->warnWhenOptionsConflict(
721+
$doNotFailOnPhpunitWarning,
722+
'--fail-on-phpunit-warning',
723+
'--do-not-fail-on-phpunit-warning',
724+
);
725+
726+
$failOnPhpunitWarning = true;
727+
728+
break;
729+
715730
case '--fail-on-empty-test-suite':
716731
$this->warnWhenOptionsConflict(
717732
$doNotFailOnEmptyTestSuite,
@@ -811,6 +826,17 @@ public function fromParameters(array $parameters): Configuration
811826

812827
break;
813828

829+
case '--do-not-fail-on-phpunit-warning':
830+
$this->warnWhenOptionsConflict(
831+
$failOnPhpunitWarning,
832+
'--do-not-fail-on-phpunit-warning',
833+
'--fail-on-phpunit-warning',
834+
);
835+
836+
$doNotFailOnPhpunitWarning = true;
837+
838+
break;
839+
814840
case '--do-not-fail-on-empty-test-suite':
815841
$this->warnWhenOptionsConflict(
816842
$failOnEmptyTestSuite,
@@ -1236,6 +1262,7 @@ public function fromParameters(array $parameters): Configuration
12361262
$failOnDeprecation,
12371263
$failOnPhpunitDeprecation,
12381264
$failOnPhpunitNotice,
1265+
$failOnPhpunitWarning,
12391266
$failOnEmptyTestSuite,
12401267
$failOnIncomplete,
12411268
$failOnNotice,
@@ -1245,6 +1272,7 @@ public function fromParameters(array $parameters): Configuration
12451272
$doNotFailOnDeprecation,
12461273
$doNotFailOnPhpunitDeprecation,
12471274
$doNotFailOnPhpunitNotice,
1275+
$doNotFailOnPhpunitWarning,
12481276
$doNotFailOnEmptyTestSuite,
12491277
$doNotFailOnIncomplete,
12501278
$doNotFailOnNotice,

src/TextUI/Configuration/Cli/Configuration.php

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
private ?bool $failOnDeprecation;
6666
private ?bool $failOnPhpunitDeprecation;
6767
private ?bool $failOnPhpunitNotice;
68+
private ?bool $failOnPhpunitWarning;
6869
private ?bool $failOnEmptyTestSuite;
6970
private ?bool $failOnIncomplete;
7071
private ?bool $failOnNotice;
@@ -74,6 +75,7 @@
7475
private ?bool $doNotFailOnDeprecation;
7576
private ?bool $doNotFailOnPhpunitDeprecation;
7677
private ?bool $doNotFailOnPhpunitNotice;
78+
private ?bool $doNotFailOnPhpunitWarning;
7779
private ?bool $doNotFailOnEmptyTestSuite;
7880
private ?bool $doNotFailOnIncomplete;
7981
private ?bool $doNotFailOnNotice;
@@ -190,7 +192,7 @@
190192
* @param ?non-empty-list<non-empty-string> $coverageFilter
191193
* @param ?non-empty-list<non-empty-string> $extensions
192194
*/
193-
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 $coverageOpenClover, ?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 $failOnPhpunitNotice, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $doNotFailOnDeprecation, ?bool $doNotFailOnPhpunitDeprecation, ?bool $doNotFailOnPhpunitNotice, ?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, ?string $otrLogfile, 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 $displayDetailsOnPhpunitNotices, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $testdoxPrinter, ?bool $testdoxPrinterSummary, bool $debug, bool $withTelemetry, ?array $extensions)
195+
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 $coverageOpenClover, ?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 $failOnPhpunitNotice, ?bool $failOnPhpunitWarning, ?bool $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnNotice, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?bool $doNotFailOnDeprecation, ?bool $doNotFailOnPhpunitDeprecation, ?bool $doNotFailOnPhpunitNotice, ?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, ?string $otrLogfile, 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 $displayDetailsOnPhpunitNotices, ?bool $displayDetailsOnTestsThatTriggerErrors, ?bool $displayDetailsOnTestsThatTriggerNotices, ?bool $displayDetailsOnTestsThatTriggerWarnings, bool $version, ?array $coverageFilter, ?string $logEventsText, ?string $logEventsVerboseText, ?bool $printerTeamCity, ?bool $testdoxPrinter, ?bool $testdoxPrinterSummary, bool $debug, bool $withTelemetry, ?array $extensions)
194196
{
195197
$this->arguments = $arguments;
196198
$this->atLeastVersion = $atLeastVersion;
@@ -228,6 +230,7 @@ public function __construct(array $arguments, ?string $atLeastVersion, ?bool $ba
228230
$this->failOnDeprecation = $failOnDeprecation;
229231
$this->failOnPhpunitDeprecation = $failOnPhpunitDeprecation;
230232
$this->failOnPhpunitNotice = $failOnPhpunitNotice;
233+
$this->failOnPhpunitWarning = $failOnPhpunitWarning;
231234
$this->failOnEmptyTestSuite = $failOnEmptyTestSuite;
232235
$this->failOnIncomplete = $failOnIncomplete;
233236
$this->failOnNotice = $failOnNotice;
@@ -237,6 +240,7 @@ public function __construct(array $arguments, ?string $atLeastVersion, ?bool $ba
237240
$this->doNotFailOnDeprecation = $doNotFailOnDeprecation;
238241
$this->doNotFailOnPhpunitDeprecation = $doNotFailOnPhpunitDeprecation;
239242
$this->doNotFailOnPhpunitNotice = $doNotFailOnPhpunitNotice;
243+
$this->doNotFailOnPhpunitWarning = $doNotFailOnPhpunitWarning;
240244
$this->doNotFailOnEmptyTestSuite = $doNotFailOnEmptyTestSuite;
241245
$this->doNotFailOnIncomplete = $doNotFailOnIncomplete;
242246
$this->doNotFailOnNotice = $doNotFailOnNotice;
@@ -996,6 +1000,26 @@ public function failOnPhpunitNotice(): bool
9961000
return $this->failOnPhpunitNotice;
9971001
}
9981002

1003+
/**
1004+
* @phpstan-assert-if-true !null $this->failOnPhpunitWarning
1005+
*/
1006+
public function hasFailOnPhpunitWarning(): bool
1007+
{
1008+
return $this->failOnPhpunitWarning !== null;
1009+
}
1010+
1011+
/**
1012+
* @throws Exception
1013+
*/
1014+
public function failOnPhpunitWarning(): bool
1015+
{
1016+
if (!$this->hasFailOnPhpunitWarning()) {
1017+
throw new Exception;
1018+
}
1019+
1020+
return $this->failOnPhpunitWarning;
1021+
}
1022+
9991023
/**
10001024
* @phpstan-assert-if-true !null $this->failOnEmptyTestSuite
10011025
*/
@@ -1176,6 +1200,26 @@ public function doNotFailOnPhpunitNotice(): bool
11761200
return $this->doNotFailOnPhpunitNotice;
11771201
}
11781202

1203+
/**
1204+
* @phpstan-assert-if-true !null $this->doNotFailOnPhpunitWarning
1205+
*/
1206+
public function hasDoNotFailOnPhpunitWarning(): bool
1207+
{
1208+
return $this->doNotFailOnPhpunitWarning !== null;
1209+
}
1210+
1211+
/**
1212+
* @throws Exception
1213+
*/
1214+
public function doNotFailOnPhpunitWarning(): bool
1215+
{
1216+
if (!$this->hasDoNotFailOnPhpunitWarning()) {
1217+
throw new Exception;
1218+
}
1219+
1220+
return $this->doNotFailOnPhpunitWarning;
1221+
}
1222+
11791223
/**
11801224
* @phpstan-assert-if-true !null $this->doNotFailOnEmptyTestSuite
11811225
*/

0 commit comments

Comments
 (0)