From 324512e379cf0d9fd3fae3fb1df2b5ce77875f80 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Sun, 11 Jun 2023 08:04:08 +0200 Subject: [PATCH] Closes #5405 --- ChangeLog-9.6.md | 1 + .../XmlConfiguration/Migration/MigrationBuilder.php | 2 +- ...ToCoverage.php => MoveWhitelistIncludesToCoverage.php} | 8 ++++++-- .../migration/_files/migration-from-92/phpunit-9.2.xml | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) rename src/TextUI/XmlConfiguration/Migration/Migrations/{MoveWhitelistDirectoriesToCoverage.php => MoveWhitelistIncludesToCoverage.php} (83%) diff --git a/ChangeLog-9.6.md b/ChangeLog-9.6.md index ee13a552264..d95dfe0e72a 100644 --- a/ChangeLog-9.6.md +++ b/ChangeLog-9.6.md @@ -6,6 +6,7 @@ All notable changes of the PHPUnit 9.6 release series are documented in this fil ### Fixed +* [#5405](https://github.com/sebastianbergmann/phpunit/issues/5405): XML configuration migration does not migrate `whitelist/file` elements * Always use `X.Y.Z` version number (and not just `X.Y`) of PHPUnit's version when checking whether a PHAR-distributed extension is compatible ## [9.6.8] - 2023-05-11 diff --git a/src/TextUI/XmlConfiguration/Migration/MigrationBuilder.php b/src/TextUI/XmlConfiguration/Migration/MigrationBuilder.php index ae3ed1c61e3..2bb663814c7 100644 --- a/src/TextUI/XmlConfiguration/Migration/MigrationBuilder.php +++ b/src/TextUI/XmlConfiguration/Migration/MigrationBuilder.php @@ -28,7 +28,7 @@ final class MigrationBuilder IntroduceCoverageElement::class, MoveAttributesFromRootToCoverage::class, MoveAttributesFromFilterWhitelistToCoverage::class, - MoveWhitelistDirectoriesToCoverage::class, + MoveWhitelistIncludesToCoverage::class, MoveWhitelistExcludesToCoverage::class, RemoveEmptyFilter::class, CoverageCloverToReport::class, diff --git a/src/TextUI/XmlConfiguration/Migration/Migrations/MoveWhitelistDirectoriesToCoverage.php b/src/TextUI/XmlConfiguration/Migration/Migrations/MoveWhitelistIncludesToCoverage.php similarity index 83% rename from src/TextUI/XmlConfiguration/Migration/Migrations/MoveWhitelistDirectoriesToCoverage.php rename to src/TextUI/XmlConfiguration/Migration/Migrations/MoveWhitelistIncludesToCoverage.php index 14e6cec83a0..c75a6d84f96 100644 --- a/src/TextUI/XmlConfiguration/Migration/Migrations/MoveWhitelistDirectoriesToCoverage.php +++ b/src/TextUI/XmlConfiguration/Migration/Migrations/MoveWhitelistIncludesToCoverage.php @@ -16,7 +16,7 @@ /** * @internal This class is not covered by the backward compatibility promise for PHPUnit */ -final class MoveWhitelistDirectoriesToCoverage implements Migration +final class MoveWhitelistIncludesToCoverage implements Migration { /** * @throws MigrationException @@ -39,7 +39,11 @@ public function migrate(DOMDocument $document): void $coverage->appendChild($include); foreach (SnapshotNodeList::fromNodeList($whitelist->childNodes) as $child) { - if (!$child instanceof DOMElement || $child->nodeName !== 'directory') { + if (!$child instanceof DOMElement) { + continue; + } + + if (!($child->nodeName === 'directory' || $child->nodeName === 'file')) { continue; } diff --git a/tests/end-to-end/migration/_files/migration-from-92/phpunit-9.2.xml b/tests/end-to-end/migration/_files/migration-from-92/phpunit-9.2.xml index b855a43ff25..40fcead786c 100644 --- a/tests/end-to-end/migration/_files/migration-from-92/phpunit-9.2.xml +++ b/tests/end-to-end/migration/_files/migration-from-92/phpunit-9.2.xml @@ -17,6 +17,7 @@ src + file.php