Skip to content

Commit 6770c48

Browse files
Implement --no-results (to complement --no-progress) and refactor progress printer and result printer selection
1 parent 75ef0d8 commit 6770c48

10 files changed

Lines changed: 131 additions & 21 deletions

File tree

ChangeLog-10.0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi
1717
* `#[ExcludeStaticPropertyFromBackup('className', 'propertyName')]` attribute for excluding a static property from the backup/restore of static properties in user-defined classes
1818
* `--log-events-text <file>` option that controls streaming of event information (without event telemetry) in text format to a file
1919
* `--log-events-verbose-text <file>` option that controls streaming of event information (with event telemetry) in text format to a file
20-
* `--no-progress` option to disable the progress output
20+
* `--no-progress` option to disable test execution progress output
21+
* `--no-results` option to disable test result output
2122
* `--no-output` option to disable all output
2223
* `--display-incomplete` option and `displayDetailsOnIncompleteTests` XML configuration attribute to control whether details on incomplete tests should be displayed
2324
* `--display-skipped` option and `displayDetailsOnSkippedTests` XML configuration attribute to control whether details on skipped tests should be displayed

src/TextUI/Configuration/Cli/Builder.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ final class Builder
7777
'no-extensions',
7878
'no-output',
7979
'no-progress',
80+
'no-results',
8081
'order-by=',
8182
'process-isolation',
8283
'repeat=',
@@ -195,6 +196,7 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
195196
$noExtensions = null;
196197
$noOutput = null;
197198
$noProgress = null;
199+
$noResults = null;
198200
$noLogging = null;
199201
$processIsolation = null;
200202
$randomOrderSeed = null;
@@ -619,6 +621,11 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
619621

620622
break;
621623

624+
case '--no-results':
625+
$noResults = true;
626+
627+
break;
628+
622629
case '--globals-backup':
623630
$backupGlobals = true;
624631

@@ -824,6 +831,7 @@ public function fromParameters(array $parameters, array $additionalLongOptions):
824831
$noExtensions,
825832
$noOutput,
826833
$noProgress,
834+
$noResults,
827835
$noLogging,
828836
$processIsolation,
829837
$randomOrderSeed,

src/TextUI/Configuration/Cli/Configuration.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ final class Configuration
7272
private readonly ?bool $noExtensions;
7373
private readonly ?bool $noOutput;
7474
private readonly ?bool $noProgress;
75+
private readonly ?bool $noResults;
7576
private readonly ?bool $noLogging;
7677
private readonly ?bool $processIsolation;
7778
private readonly ?int $randomOrderSeed;
@@ -109,7 +110,7 @@ final class Configuration
109110
private readonly ?string $logEventsText;
110111
private readonly ?string $logEventsVerboseText;
111112

112-
public function __construct(?string $argument, ?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 $configuration, ?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 $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?string $filter, ?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 $noLogging, ?bool $processIsolation, ?int $randomOrderSeed, ?int $repeat, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?bool $stopOnDefect, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?string $testdoxXmlFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, ?string $unrecognizedOrderBy, ?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)
113+
public function __construct(?string $argument, ?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 $configuration, ?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 $failOnEmptyTestSuite, ?bool $failOnIncomplete, ?bool $failOnRisky, ?bool $failOnSkipped, ?bool $failOnWarning, ?string $filter, ?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, ?int $repeat, ?bool $reportUselessTests, ?bool $resolveDependencies, ?bool $reverseList, ?bool $stderr, ?bool $strictCoverage, ?bool $stopOnDefect, ?bool $stopOnError, ?bool $stopOnFailure, ?bool $stopOnIncomplete, ?bool $stopOnRisky, ?bool $stopOnSkipped, ?bool $stopOnWarning, ?string $teamcityLogfile, ?string $testdoxHtmlFile, ?string $testdoxTextFile, ?string $testdoxXmlFile, ?array $testSuffixes, ?string $testSuite, ?string $excludeTestSuite, ?string $unrecognizedOrderBy, ?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)
113114
{
114115
$this->argument = $argument;
115116
$this->atLeastVersion = $atLeastVersion;
@@ -167,6 +168,7 @@ public function __construct(?string $argument, ?string $atLeastVersion, ?bool $b
167168
$this->noExtensions = $noExtensions;
168169
$this->noOutput = $noOutput;
169170
$this->noProgress = $noProgress;
171+
$this->noResults = $noResults;
170172
$this->noLogging = $noLogging;
171173
$this->processIsolation = $processIsolation;
172174
$this->randomOrderSeed = $randomOrderSeed;
@@ -1325,6 +1327,26 @@ public function noProgress(): bool
13251327
return $this->noProgress;
13261328
}
13271329

1330+
/**
1331+
* @psalm-assert-if-true !null $this->noResults
1332+
*/
1333+
public function hasNoResults(): bool
1334+
{
1335+
return $this->noResults !== null;
1336+
}
1337+
1338+
/**
1339+
* @throws Exception
1340+
*/
1341+
public function noResults(): bool
1342+
{
1343+
if ($this->noResults === null) {
1344+
throw new Exception;
1345+
}
1346+
1347+
return $this->noResults;
1348+
}
1349+
13281350
/**
13291351
* @psalm-assert-if-true !null $this->noLogging
13301352
*/

src/TextUI/Configuration/Configuration.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ final class Configuration
9595
private bool $requireCoverageMetadata;
9696
private bool $registerMockObjectsFromTestArgumentsRecursively;
9797
private bool $noProgress;
98+
private bool $noResults;
99+
private bool $noOutput;
98100
private int $executionOrder;
99101
private int $executionOrderDefects;
100102
private bool $resolveDependencies;
@@ -108,7 +110,6 @@ final class Configuration
108110
private ?string $logEventsVerboseText;
109111
private ?array $testsCovering;
110112
private ?array $testsUsing;
111-
private bool $defaultOutput;
112113
private bool $teamCityOutput;
113114
private bool $testDoxOutput;
114115
private int $repeat;
@@ -123,7 +124,7 @@ final class Configuration
123124
/**
124125
* @psalm-param list<array{className: class-string, parameters: array<string, string>}> $extensionBootstrappers
125126
*/
126-
public function __construct(?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, 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 $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $outputToStandardErrorStream, int|string $columns, bool $tooFewColumnsRequested, bool $loadPharExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $stopOnDefect, bool $stopOnError, bool $stopOnFailure, bool $stopOnWarning, bool $stopOnIncomplete, bool $stopOnRisky, bool $stopOnSkipped, 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, int $executionOrder, int $executionOrderDefects, bool $resolveDependencies, ?string $logfileText, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logfileTestdoxXml, ?string $logEventsText, ?string $logEventsVerboseText, bool $defaultOutput, bool $teamCityOutput, bool $testDoxOutput, int $repeat, ?array $testsCovering, ?array $testsUsing, ?string $filter, ?array $groups, ?array $excludeGroups, ?string $includePath, int $randomOrderSeed, bool $includeUncoveredFiles, ?string $xmlValidationErrors)
127+
public function __construct(?string $configurationFile, ?string $bootstrap, bool $cacheResult, ?string $cacheDirectory, ?string $coverageCacheDirectory, 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 $failOnEmptyTestSuite, bool $failOnIncomplete, bool $failOnRisky, bool $failOnSkipped, bool $failOnWarning, bool $outputToStandardErrorStream, int|string $columns, bool $tooFewColumnsRequested, bool $loadPharExtensions, ?string $pharExtensionDirectory, array $extensionBootstrappers, bool $backupGlobals, bool $backupStaticProperties, bool $beStrictAboutChangesToGlobalState, bool $colors, bool $processIsolation, bool $stopOnDefect, bool $stopOnError, bool $stopOnFailure, bool $stopOnWarning, bool $stopOnIncomplete, bool $stopOnRisky, bool $stopOnSkipped, 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 $logfileText, ?string $logfileTeamcity, ?string $logfileJunit, ?string $logfileTestdoxHtml, ?string $logfileTestdoxText, ?string $logfileTestdoxXml, ?string $logEventsText, ?string $logEventsVerboseText, bool $teamCityOutput, bool $testDoxOutput, int $repeat, ?array $testsCovering, ?array $testsUsing, ?string $filter, ?array $groups, ?array $excludeGroups, ?string $includePath, int $randomOrderSeed, bool $includeUncoveredFiles, ?string $xmlValidationErrors)
127128
{
128129
$this->configurationFile = $configurationFile;
129130
$this->bootstrap = $bootstrap;
@@ -193,6 +194,8 @@ public function __construct(?string $configurationFile, ?string $bootstrap, bool
193194
$this->requireCoverageMetadata = $requireCoverageMetadata;
194195
$this->registerMockObjectsFromTestArgumentsRecursively = $registerMockObjectsFromTestArgumentsRecursively;
195196
$this->noProgress = $noProgress;
197+
$this->noResults = $noResults;
198+
$this->noOutput = $noOutput;
196199
$this->executionOrder = $executionOrder;
197200
$this->executionOrderDefects = $executionOrderDefects;
198201
$this->resolveDependencies = $resolveDependencies;
@@ -204,7 +207,6 @@ public function __construct(?string $configurationFile, ?string $bootstrap, bool
204207
$this->logfileTestdoxXml = $logfileTestdoxXml;
205208
$this->logEventsText = $logEventsText;
206209
$this->logEventsVerboseText = $logEventsVerboseText;
207-
$this->defaultOutput = $defaultOutput;
208210
$this->teamCityOutput = $teamCityOutput;
209211
$this->testDoxOutput = $testDoxOutput;
210212
$this->repeat = $repeat;
@@ -768,6 +770,16 @@ public function noProgress(): bool
768770
return $this->noProgress;
769771
}
770772

773+
public function noResults(): bool
774+
{
775+
return $this->noResults;
776+
}
777+
778+
public function noOutput(): bool
779+
{
780+
return $this->noOutput;
781+
}
782+
771783
public function executionOrder(): int
772784
{
773785
return $this->executionOrder;
@@ -943,11 +955,6 @@ public function logEventsVerboseText(): string
943955
return $this->logEventsVerboseText;
944956
}
945957

946-
public function outputIsDefault(): bool
947-
{
948-
return $this->defaultOutput;
949-
}
950-
951958
public function outputIsTeamCity(): bool
952959
{
953960
return $this->teamCityOutput;

src/TextUI/Configuration/Merger.php

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -524,18 +524,16 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
524524
$logEventsVerboseText = $cliConfiguration->logEventsVerboseText();
525525
}
526526

527-
$defaultOutput = true;
528527
$teamCityOutput = false;
529-
$testDoxOutput = false;
530528

531529
if ($cliConfiguration->hasTeamCityPrinter() && $cliConfiguration->teamCityPrinter()) {
532530
$teamCityOutput = true;
533-
$defaultOutput = false;
534-
} elseif ($cliConfiguration->hasTestDoxPrinter() && $cliConfiguration->testdoxPrinter()) {
531+
}
532+
533+
$testDoxOutput = false;
534+
535+
if ($cliConfiguration->hasTestDoxPrinter() && $cliConfiguration->testdoxPrinter()) {
535536
$testDoxOutput = true;
536-
$defaultOutput = false;
537-
} elseif ($cliConfiguration->hasNoOutput() && $cliConfiguration->noOutput()) {
538-
$defaultOutput = false;
539537
}
540538

541539
$noProgress = false;
@@ -544,6 +542,18 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
544542
$noProgress = true;
545543
}
546544

545+
$noResults = false;
546+
547+
if ($cliConfiguration->hasNoResults() && $cliConfiguration->noResults()) {
548+
$noResults = true;
549+
}
550+
551+
$noOutput = false;
552+
553+
if ($cliConfiguration->hasNoOutput() && $cliConfiguration->noOutput()) {
554+
$noOutput = true;
555+
}
556+
547557
$repeat = 0;
548558

549559
if ($cliConfiguration->hasRepeat()) {
@@ -679,6 +689,8 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
679689
$requireCoverageMetadata,
680690
$registerMockObjectsFromTestArgumentsRecursively,
681691
$noProgress,
692+
$noResults,
693+
$noOutput,
682694
$executionOrder,
683695
$executionOrderDefects,
684696
$resolveDependencies,
@@ -690,7 +702,6 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
690702
$logfileTestdoxXml,
691703
$logEventsText,
692704
$logEventsVerboseText,
693-
$defaultOutput,
694705
$teamCityOutput,
695706
$testDoxOutput,
696707
$repeat,

src/TextUI/Help.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ final class Help
109109
['spacer' => ''],
110110

111111
['arg' => '--no-progress', 'desc' => 'Disable output of test execution progress'],
112+
['arg' => '--no-results', 'desc' => 'Disable output of test results'],
112113
['arg' => '--no-output', 'desc' => 'Disable all output'],
113114
['spacer' => ''],
114115

0 commit comments

Comments
 (0)