From 3449010c73e7f265416c85fece0c39f2fcf5af04 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 20 Dec 2024 11:28:26 +0100 Subject: [PATCH 1/2] Refactor --- .../TextUI/Configuration/Xml/MigratorTest.php | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/tests/unit/TextUI/Configuration/Xml/MigratorTest.php b/tests/unit/TextUI/Configuration/Xml/MigratorTest.php index b05e1e0bccd..96f93144e1d 100644 --- a/tests/unit/TextUI/Configuration/Xml/MigratorTest.php +++ b/tests/unit/TextUI/Configuration/Xml/MigratorTest.php @@ -9,35 +9,32 @@ */ namespace PHPUnit\TextUI\XmlConfiguration; -use PHPUnit\Framework\Attributes\TestDox; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; use PHPUnit\Util\Xml\Loader as XmlLoader; final class MigratorTest extends TestCase { - #[TestDox('Can migrate PHPUnit 9.2 configuration')] - public function testCanMigratePhpUnit92Configuration(): void + public static function provider(): array { - $this->assertEquals( - (new XmlLoader)->loadFile(__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-9.2.xml'), - (new XmlLoader)->load( - (new Migrator)->migrate( - __DIR__ . '/../../../../_files/XmlConfigurationMigration/input-9.2.xml', - ), - ), - ); + return [ + 'PHPUnit 9.2' => [ + __DIR__ . '/../../../../_files/XmlConfigurationMigration/output-9.2.xml', + __DIR__ . '/../../../../_files/XmlConfigurationMigration/input-9.2.xml', + ], + 'PHPUnit 9.5' => [ + __DIR__ . '/../../../../_files/XmlConfigurationMigration/output-9.5.xml', + __DIR__ . '/../../../../_files/XmlConfigurationMigration/input-9.5.xml', + ], + ]; } - #[TestDox('Can migrate PHPUnit 9.5 configuration')] - public function testCanMigratePhpUnit95Configuration(): void + #[DataProvider('provider')] + public function testCanMigrateConfigurationFileThatValidatesAgainstPreviousSchema(string $output, string $input): void { $this->assertEquals( - (new XmlLoader)->loadFile(__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-9.5.xml'), - (new XmlLoader)->load( - (new Migrator)->migrate( - __DIR__ . '/../../../../_files/XmlConfigurationMigration/input-9.5.xml', - ), - ), + (new XmlLoader)->loadFile($output), + (new XmlLoader)->load((new Migrator)->migrate($input)), ); } } From e4e732d67023456e83014b45306875eb7de7cc4d Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 20 Dec 2024 11:31:53 +0100 Subject: [PATCH 2/2] Closes #6087 --- ChangeLog-10.5.md | 1 + .../Configuration/Xml/Migration/MigrationBuilder.php | 4 ++++ .../XmlConfigurationMigration/input-issue-6087.xml | 11 +++++++++++ .../XmlConfigurationMigration/output-issue-6087.xml | 10 ++++++++++ tests/unit/TextUI/Configuration/Xml/MigratorTest.php | 4 ++++ 5 files changed, 30 insertions(+) create mode 100644 tests/_files/XmlConfigurationMigration/input-issue-6087.xml create mode 100644 tests/_files/XmlConfigurationMigration/output-issue-6087.xml diff --git a/ChangeLog-10.5.md b/ChangeLog-10.5.md index 862d1370d17..5b797fdf83d 100644 --- a/ChangeLog-10.5.md +++ b/ChangeLog-10.5.md @@ -7,6 +7,7 @@ All notable changes of the PHPUnit 10.5 release series are documented in this fi ### Fixed * [#6082](https://github.com/sebastianbergmann/phpunit/issues/6082): `assertArrayHasKey()`, `assertArrayNotHasKey()`, `arrayHasKey()`, and `ArrayHasKey::__construct()` do not support all possible key types +* [#6087](https://github.com/sebastianbergmann/phpunit/issues/6087): `--migrate-configuration` does not remove `beStrictAboutTodoAnnotatedTests` attribute from XML configuration file ## [10.5.39] - 2024-12-11 diff --git a/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php b/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php index 147c4066dcc..212281fee15 100644 --- a/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php +++ b/src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php @@ -63,6 +63,10 @@ final class MigrationBuilder '10.0' => [ MoveCoverageDirectoriesToSource::class, ], + + '10.4' => [ + RemoveBeStrictAboutTodoAnnotatedTestsAttribute::class, + ], ]; public function build(string $fromVersion): array diff --git a/tests/_files/XmlConfigurationMigration/input-issue-6087.xml b/tests/_files/XmlConfigurationMigration/input-issue-6087.xml new file mode 100644 index 00000000000..02d55bc3208 --- /dev/null +++ b/tests/_files/XmlConfigurationMigration/input-issue-6087.xml @@ -0,0 +1,11 @@ + + + + + tests + + + diff --git a/tests/_files/XmlConfigurationMigration/output-issue-6087.xml b/tests/_files/XmlConfigurationMigration/output-issue-6087.xml new file mode 100644 index 00000000000..7bb9a89faf1 --- /dev/null +++ b/tests/_files/XmlConfigurationMigration/output-issue-6087.xml @@ -0,0 +1,10 @@ + + + + + tests + + + diff --git a/tests/unit/TextUI/Configuration/Xml/MigratorTest.php b/tests/unit/TextUI/Configuration/Xml/MigratorTest.php index 96f93144e1d..841fa7e2ecc 100644 --- a/tests/unit/TextUI/Configuration/Xml/MigratorTest.php +++ b/tests/unit/TextUI/Configuration/Xml/MigratorTest.php @@ -26,6 +26,10 @@ public static function provider(): array __DIR__ . '/../../../../_files/XmlConfigurationMigration/output-9.5.xml', __DIR__ . '/../../../../_files/XmlConfigurationMigration/input-9.5.xml', ], + 'Issue 6087' => [ + __DIR__ . '/../../../../_files/XmlConfigurationMigration/output-issue-6087.xml', + __DIR__ . '/../../../../_files/XmlConfigurationMigration/input-issue-6087.xml', + ], ]; }