Skip to content

Commit

Permalink
Implement --only-summary-for-coverage-text and --show-uncovered-for-c…
Browse files Browse the repository at this point in the history
…overage-text CLI options
  • Loading branch information
sebastianbergmann committed Mar 6, 2024
1 parent e3d9a1b commit 4f31ea0
Show file tree
Hide file tree
Showing 6 changed files with 288 additions and 255 deletions.
2 changes: 2 additions & 0 deletions ChangeLog-11.1.md
Expand Up @@ -8,6 +8,8 @@ All notable changes of the PHPUnit 11.1 release series are documented in this fi

* [#5175](https://github.com/sebastianbergmann/phpunit/issues/5175): `#[CoversMethod]` and `#[UsesMethod]` attributes for more fine-grained code coverage targeting
* [#5696](https://github.com/sebastianbergmann/phpunit/pull/5696): `#[DisableReturnValueGenerationForTestDoubles]` attribute for disabling return value generation for test doubles created using `createMock()`, `createMockForIntersectionOfInterfaces()`, `createPartialMock()`, `createStub()`, and `createStubForIntersectionOfInterfaces()`
* `--only-summary-for-coverage-text` CLI option to reduce the code coverage report in text format to a summary
* `--show-uncovered-for-coverage-text` CLI option to expand the code coverage report in text format to include a list of uncovered files

### Changed

Expand Down
16 changes: 13 additions & 3 deletions src/TextUI/Configuration/Cli/Builder.php
Expand Up @@ -47,6 +47,8 @@ final class Builder
'coverage-html=',
'coverage-php=',
'coverage-text==',
'only-summary-for-coverage-text',
'show-uncovered-for-coverage-text',
'coverage-xml=',
'path-coverage',
'disallow-test-output',
Expand Down Expand Up @@ -331,9 +333,17 @@ public function fromParameters(array $parameters): Configuration
$option[1] = 'php://stdout';
}

$coverageText = $option[1];
$coverageTextShowUncoveredFiles = false;
$coverageTextShowOnlySummary = false;
$coverageText = $option[1];

break;

case '--only-summary-for-coverage-text':
$coverageTextShowOnlySummary = true;

break;

case '--show-uncovered-for-coverage-text':
$coverageTextShowUncoveredFiles = true;

break;

Expand Down
8 changes: 8 additions & 0 deletions src/TextUI/Configuration/Merger.php
Expand Up @@ -333,6 +333,14 @@ public function merge(CliConfiguration $cliConfiguration, XmlConfiguration $xmlC
$coverageTextShowOnlySummary = $xmlConfiguration->codeCoverage()->text()->showOnlySummary();
}

if ($cliConfiguration->hasCoverageTextShowUncoveredFiles()) {
$coverageTextShowUncoveredFiles = $cliConfiguration->coverageTextShowUncoveredFiles();
}

if ($cliConfiguration->hasCoverageTextShowOnlySummary()) {
$coverageTextShowOnlySummary = $cliConfiguration->coverageTextShowOnlySummary();
}

if ($cliConfiguration->hasCoverageText()) {
$coverageText = $cliConfiguration->coverageText();
} elseif ($coverageFromXmlConfiguration && $xmlConfiguration->codeCoverage()->hasText()) {
Expand Down
2 changes: 2 additions & 0 deletions src/TextUI/Help.php
Expand Up @@ -270,6 +270,8 @@ private function elements(): array
['arg' => '--coverage-html <dir>', 'desc' => 'Write code coverage report in HTML format to directory'],
['arg' => '--coverage-php <file>', 'desc' => 'Write serialized code coverage data to file'],
['arg' => '--coverage-text=<file>', 'desc' => 'Write code coverage report in text format to file [default: standard output]'],
['arg' => '--only-summary-for-coverage-text', 'desc' => 'Option for code coverage report in text format: only show summary'],
['arg' => '--show-uncovered-for-coverage-text', 'desc' => 'Option for code coverage report in text format: show uncovered files'],
['arg' => '--coverage-xml <dir>', 'desc' => 'Write code coverage report in XML format to directory'],
['arg' => '--warm-coverage-cache', 'desc' => 'Warm static analysis cache'],
['arg' => '--coverage-filter <dir>', 'desc' => 'Include <dir> in code coverage reporting'],
Expand Down

0 comments on commit 4f31ea0

Please sign in to comment.