From ee2a7c66e5c7bc51d348daecaed5e2d35fe3857e Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Wed, 18 Sep 2024 13:33:56 +0200 Subject: [PATCH] Closes #5951 --- ChangeLog-11.4.md | 4 +++ DEPRECATIONS.md | 1 + phpunit.xsd | 1 - .../Xml/Migration/MigrationBuilder.php | 4 +++ ...eElementIncludeUncoveredFilesAttribute.php | 34 +++++++++++++++++++ .../XmlConfigurationMigration/output-9.2.xml | 3 +- 6 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/TextUI/Configuration/Xml/Migration/Migrations/RemoveCoverageElementIncludeUncoveredFilesAttribute.php diff --git a/ChangeLog-11.4.md b/ChangeLog-11.4.md index 189f3a2aa09..f5c09aac994 100644 --- a/ChangeLog-11.4.md +++ b/ChangeLog-11.4.md @@ -16,4 +16,8 @@ All notable changes of the PHPUnit 11.4 release series are documented in this fi * The output of `--list-groups` now shows how many tests a group contains * The output of `--list-suites` now shows how many tests a test suite contains +### Deprecated + +* [#5951](https://github.com/sebastianbergmann/phpunit/issues/5951): `includeUncoveredFiles` configuration option + [11.4.0]: https://github.com/sebastianbergmann/phpunit/compare/11.3...main diff --git a/DEPRECATIONS.md b/DEPRECATIONS.md index 1f8157b9d7e..00a30bec6ed 100644 --- a/DEPRECATIONS.md +++ b/DEPRECATIONS.md @@ -58,3 +58,4 @@ This functionality is currently [hard-deprecated](https://phpunit.de/backward-co | [#5214](https://github.com/sebastianbergmann/phpunit/issues/5214) | `TestCase::iniSet()` | 10.3.0 | | | [#5216](https://github.com/sebastianbergmann/phpunit/issues/5216) | `TestCase::setLocale()` | 10.3.0 | | | [#5800](https://github.com/sebastianbergmann/phpunit/issues/5800) | Targeting traits with `#[CoversClass]` and `#[UsesClass]` | 11.2.0 | `#[CoversClass]` and `#[UsesTrait]` | +| [#5951](https://github.com/sebastianbergmann/phpunit/issues/5951) | `includeUncoveredFiles` configuration option | 11.4.0 | | diff --git a/phpunit.xsd b/phpunit.xsd index b8d8e408c3e..52db363026a 100644 --- a/phpunit.xsd +++ b/phpunit.xsd @@ -64,7 +64,6 @@ - diff --git a/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php b/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php index c56427284a7..45923abdc44 100644 --- a/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php +++ b/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php @@ -76,6 +76,10 @@ RemoveCacheResultFileAttribute::class, RemoveCoverageElementCacheDirectoryAttribute::class, ], + + '11.4' => [ + RemoveCoverageElementIncludeUncoveredFilesAttribute::class, + ], ]; /** diff --git a/src/TextUI/Configuration/Xml/Migration/Migrations/RemoveCoverageElementIncludeUncoveredFilesAttribute.php b/src/TextUI/Configuration/Xml/Migration/Migrations/RemoveCoverageElementIncludeUncoveredFilesAttribute.php new file mode 100644 index 00000000000..b49d75314f4 --- /dev/null +++ b/src/TextUI/Configuration/Xml/Migration/Migrations/RemoveCoverageElementIncludeUncoveredFilesAttribute.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ +namespace PHPUnit\TextUI\XmlConfiguration; + +use DOMDocument; +use DOMElement; + +/** + * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit + * + * @internal This class is not covered by the backward compatibility promise for PHPUnit + */ +final readonly class RemoveCoverageElementIncludeUncoveredFilesAttribute implements Migration +{ + public function migrate(DOMDocument $document): void + { + $node = $document->getElementsByTagName('coverage')->item(0); + + if (!$node instanceof DOMElement || $node->parentNode === null) { + return; + } + + if ($node->hasAttribute('includeUncoveredFiles')) { + $node->removeAttribute('includeUncoveredFiles'); + } + } +} diff --git a/tests/_files/XmlConfigurationMigration/output-9.2.xml b/tests/_files/XmlConfigurationMigration/output-9.2.xml index 6ceef27a604..350ddccd633 100644 --- a/tests/_files/XmlConfigurationMigration/output-9.2.xml +++ b/tests/_files/XmlConfigurationMigration/output-9.2.xml @@ -3,8 +3,7 @@ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd" cacheDirectory=".phpunit.cache"> -