Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: allow for running on PHPUnit 10/11
Until now, the tests would run on PHPUnit 9 for PHP 7.3 and higher. PHPUnit 10 (PHP 8.1+) was released in February 2023, PHPUnit 11 (PHP 8.2+) in February 2024 and the update for this test suite is quite painless, so let's allow for running the tests on PHPUnit 10 and 11. This commit actions this. Things to be aware of: Handling of PHPUnit deprecations Prior to PHPUnit 10.5.32 and PHPUnit 11.3.3, if the `failOnDeprecation` attribute was set (previously: `convertDeprecationsToExceptions`), tests runs would not only fail on PHP deprecation notices, but also on PHPUnit native deprecation notices when running on PHPUnit 10/11. This undesireable behaviour has now (finally) been reverted, which makes updating test suites for compatibility with PHPUnit 10/11 a lot more straight-forward. This is the reason that the minimum PHPUnit 10/11 versions in the `composer.json` file are set to such specific versions. As part of this change, PHPUnit 10.5.32 and 11.3.3 introduce two new options for both the configuration file and as CLI arguments: `displayDetailsOnPhpunitDeprecations` and `failOnPhpunitDeprecation`, both of which will default to `false`. These options have been added to the PHPUnit configuration for PHPUnit 10/11 to safeguard them against changes in the default value. Test configuration file changes The configuration file specification has undergone changes in PHPUnit 9.3 and 10.0. Most notably: * In PHPUnit 9.3, the manner of specifying the code coverage configuration has changed. * In PHPUnit 10.0, a significant number of attributes of the `<phpunit>` element were removed or renamed. While the `--migrate-configuration` command can upgrade a configuration for the changes in the format made in PHPUnit 9.3, some of the changes in the configuration format in PHPUnit 10 don't have one-on-one replacements and/or are not taken into account. With that in mind, I deem it more appropriate to have a dedicated PHPUnit configuration file for PHPUnit 10+ to ensure the test run will behave as intended. To that end: * The `phpunit.xml.dist` file has been renamed to `phpunitlte9.xml.dist` (for PHPUnit <= 9) and a new `phpunit.xml.dist` file has been added for PHPUnit 10+. * The renamed file is set to be excluded from release archives via `.gitattributes` and a potential local overload file for it is set to be ignored by default via the `.gitignore` file. * Additional scripts have been added to the `composer.json` file to run the tests either with the new or the old configuration file. * The GH Actions `test` workflow has been updated to select the correct configuration file based on the PHPUnit version on which the tests are being run. Other command/config changes Also note that the `--coverage-cache <dir>` CLI flag was deprecated in PHPUnit 10 and removed in PHPUnit 11. A generic `cacheDirectory` attribute is the recommended replacement (though a CLI option is also available). The new attribute has been added to the PHPUnit 10+ config file, while for PHPUnit 9.3 - 9.5, the flag is still added to the command in CI (as adding the PHPUnit 9.3 equivalent to the config file would make the config incompatible with PHPUnit < 9.3). Composer will not install PHPUnit 11 Psalm 5 has a dependency on PHP-Parser 4, while PHPUnit 11 requires PHP-Parser 5, so Psalm currently effectively blocks the installation of PHPUnit 11 via Composer. Running the tests on PHPUnit 11 will work fine though (tested with a PHAR file). Ref: * https://phpunit.de/announcements/phpunit-11.html * https://phpunit.de/announcements/phpunit-10.html
- Loading branch information