Skip to content

Commit bb142b5

Browse files
Closes #6376
1 parent 6782007 commit bb142b5

File tree

23 files changed

+458
-12
lines changed

23 files changed

+458
-12
lines changed

ChangeLog-12.5.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ All notable changes of the PHPUnit 12.5 release series are documented in this fi
44

55
## [12.5.0] - 2025-12-05
66

7+
### Added
8+
9+
* [#6376](https://github.com/sebastianbergmann/phpunit/issues/6376): `--all` CLI option to ignore test selection configured in XML configuration file
10+
711
[12.5.0]: https://github.com/sebastianbergmann/phpunit/compare/12.4...main

src/TextUI/Command/Commands/ListTestSuitesCommand.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ private function warnAboutConflictingOptions(): string
6969

7070
$configuration = Registry::get();
7171

72-
if ($configuration->hasDefaultTestSuite()) {
73-
$buffer .= 'The defaultTestSuite (XML) and --list-suites (CLI) options cannot be combined, only the default test suite is shown' . PHP_EOL;
74-
}
75-
7672
if ($configuration->includeTestSuites() !== [] && !$configuration->hasDefaultTestSuite()) {
7773
$buffer .= 'The --testsuite and --list-suites options cannot be combined, --testsuite is ignored' . PHP_EOL;
7874
}

src/TextUI/Configuration/Cli/Builder.php

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ final class Builder
3535
* @var non-empty-list<non-empty-string>
3636
*/
3737
private const array LONG_OPTIONS = [
38+
'all',
3839
'atleast-version=',
3940
'bootstrap=',
4041
'cache-result',
@@ -190,6 +191,7 @@ public function fromParameters(array $parameters): Configuration
190191
);
191192
}
192193

194+
$all = null;
193195
$atLeastVersion = null;
194196
$backupGlobals = null;
195197
$backupStaticProperties = null;
@@ -318,6 +320,65 @@ public function fromParameters(array $parameters): Configuration
318320
$optionAllowedMultipleTimes = false;
319321

320322
switch ($option[0]) {
323+
case '--all':
324+
$this->warnWhenOptionsConflict(
325+
$testSuite,
326+
'--all',
327+
'--testsuite',
328+
);
329+
330+
$this->warnWhenOptionsConflict(
331+
$excludeTestSuite,
332+
'--all',
333+
'--exclude-testsuite',
334+
);
335+
336+
$this->warnWhenOptionsConflict(
337+
$groups,
338+
'--all',
339+
'--group',
340+
);
341+
342+
$this->warnWhenOptionsConflict(
343+
$excludeGroups,
344+
'--all',
345+
'--exclude-group',
346+
);
347+
348+
$this->warnWhenOptionsConflict(
349+
$testsCovering,
350+
'--all',
351+
'--covers',
352+
);
353+
354+
$this->warnWhenOptionsConflict(
355+
$testsUsing,
356+
'--all',
357+
'--uses',
358+
);
359+
360+
$this->warnWhenOptionsConflict(
361+
$testsRequiringPhpExtension,
362+
'--all',
363+
'--requires-php-extension',
364+
);
365+
366+
$this->warnWhenOptionsConflict(
367+
$filter,
368+
'--all',
369+
'--filter',
370+
);
371+
372+
$this->warnWhenOptionsConflict(
373+
$excludeFilter,
374+
'--all',
375+
'--exclude-filter',
376+
);
377+
378+
$all = true;
379+
380+
break;
381+
321382
case '--colors':
322383
$colors = \PHPUnit\TextUI\Configuration\Configuration::COLOR_AUTO;
323384

@@ -452,21 +513,45 @@ public function fromParameters(array $parameters): Configuration
452513
break;
453514

454515
case '--filter':
516+
$this->warnWhenOptionsConflict(
517+
$all,
518+
'--filter',
519+
'--all',
520+
);
521+
455522
$filter = $option[1];
456523

457524
break;
458525

459526
case '--exclude-filter':
527+
$this->warnWhenOptionsConflict(
528+
$all,
529+
'--exclude-filter',
530+
'--all',
531+
);
532+
460533
$excludeFilter = $option[1];
461534

462535
break;
463536

464537
case '--testsuite':
538+
$this->warnWhenOptionsConflict(
539+
$all,
540+
'--testsuite',
541+
'--all',
542+
);
543+
465544
$testSuite = $option[1];
466545

467546
break;
468547

469548
case '--exclude-testsuite':
549+
$this->warnWhenOptionsConflict(
550+
$all,
551+
'--exclude-testsuite',
552+
'--all',
553+
);
554+
470555
$excludeTestSuite = $option[1];
471556

472557
break;
@@ -505,6 +590,12 @@ public function fromParameters(array $parameters): Configuration
505590
break;
506591

507592
case '--group':
593+
$this->warnWhenOptionsConflict(
594+
$all,
595+
'--group',
596+
'--all',
597+
);
598+
508599
if ($groups === null) {
509600
$groups = [];
510601
}
@@ -516,6 +607,12 @@ public function fromParameters(array $parameters): Configuration
516607
break;
517608

518609
case '--exclude-group':
610+
$this->warnWhenOptionsConflict(
611+
$all,
612+
'--exclude-group',
613+
'--all',
614+
);
615+
519616
if ($excludeGroups === null) {
520617
$excludeGroups = [];
521618
}
@@ -527,6 +624,12 @@ public function fromParameters(array $parameters): Configuration
527624
break;
528625

529626
case '--covers':
627+
$this->warnWhenOptionsConflict(
628+
$all,
629+
'--covers',
630+
'--all',
631+
);
632+
530633
if ($testsCovering === null) {
531634
$testsCovering = [];
532635
}
@@ -538,6 +641,12 @@ public function fromParameters(array $parameters): Configuration
538641
break;
539642

540643
case '--uses':
644+
$this->warnWhenOptionsConflict(
645+
$all,
646+
'--uses',
647+
'--all',
648+
);
649+
541650
if ($testsUsing === null) {
542651
$testsUsing = [];
543652
}
@@ -549,6 +658,12 @@ public function fromParameters(array $parameters): Configuration
549658
break;
550659

551660
case '--requires-php-extension':
661+
$this->warnWhenOptionsConflict(
662+
$all,
663+
'--requires-php-extension',
664+
'--all',
665+
);
666+
552667
if ($testsRequiringPhpExtension === null) {
553668
$testsRequiringPhpExtension = [];
554669
}
@@ -1242,6 +1357,7 @@ public function fromParameters(array $parameters): Configuration
12421357

12431358
return new Configuration(
12441359
$options[1],
1360+
$all,
12451361
$atLeastVersion,
12461362
$backupGlobals,
12471363
$backupStaticProperties,
@@ -1392,9 +1508,10 @@ private function markProcessed(string $option): void
13921508
}
13931509

13941510
/**
1395-
* @param non-empty-string $option
1511+
* @param null|array<non-empty-string>|bool|string $current
1512+
* @param non-empty-string $option
13961513
*/
1397-
private function warnWhenOptionsConflict(?bool $current, string $option, string $opposite): void
1514+
private function warnWhenOptionsConflict(null|array|bool|string $current, string $option, string $opposite): void
13981515
{
13991516
if ($current === null) {
14001517
return;

src/TextUI/Configuration/Cli/Configuration.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* @var list<non-empty-string>
2323
*/
2424
private array $arguments;
25+
private ?bool $all;
2526
private ?string $atLeastVersion;
2627
private ?bool $backupGlobals;
2728
private ?bool $backupStaticProperties;
@@ -194,9 +195,10 @@
194195
* @param ?non-empty-list<non-empty-string> $coverageFilter
195196
* @param ?non-empty-list<non-empty-string> $extensions
196197
*/
197-
public function __construct(array $arguments, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, bool $checkPhpConfiguration, 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 $includeGitInformation, 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)
198+
public function __construct(array $arguments, ?bool $all, ?string $atLeastVersion, ?bool $backupGlobals, ?bool $backupStaticProperties, ?bool $beStrictAboutChangesToGlobalState, ?string $bootstrap, ?string $cacheDirectory, ?bool $cacheResult, bool $checkPhpConfiguration, 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 $includeGitInformation, 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)
198199
{
199200
$this->arguments = $arguments;
201+
$this->all = $all;
200202
$this->atLeastVersion = $atLeastVersion;
201203
$this->backupGlobals = $backupGlobals;
202204
$this->backupStaticProperties = $backupStaticProperties;
@@ -330,6 +332,26 @@ public function arguments(): array
330332
return $this->arguments;
331333
}
332334

335+
/**
336+
* @phpstan-assert-if-true !null $this->all
337+
*/
338+
public function hasAll(): bool
339+
{
340+
return $this->all !== null;
341+
}
342+
343+
/**
344+
* @throws Exception
345+
*/
346+
public function all(): bool
347+
{
348+
if (!$this->hasAll()) {
349+
throw new Exception;
350+
}
351+
352+
return $this->all;
353+
}
354+
333355
/**
334356
* @phpstan-assert-if-true !null $this->atLeastVersion
335357
*/

0 commit comments

Comments
 (0)