Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 | Make tests compatible with PHPUnit 10 #157

Merged
merged 2 commits into from
Apr 10, 2024

Conversation

jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Mar 16, 2024

Tests: make dataproviders static

As of PHPUnit 10, data providers are (again) expected to be static methods.

This updates the test suite to respect that.

Includes removing the use of $this from select data providers.

Refs:

PHPUnit: allow for PHPUnit 10 + add separate configuration

The PHPunit configuration file specification has undergone changes in PHPUnit 9.3, 10.0 and 10.1.

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.
  • In PHPUnit 10.1, there is another change related to the code coverage configuration + the ability to fail builds on deprecations/warnings/notices is brought back.

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.

As this package is used in the CI pipeline for other packages, it is important for this package to be ready for new PHP releases early, so failing the test suite on deprecatios/notices and warnings is appropriate.

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.

This commit adds this dedicated configuration file for PHPUnit 10.1+.

Includes:

  • Ignoring the new file for package archives.
  • Allowing for a local override file.
  • Adding scripts to the composer.json file to run the tests using this new configuration file and make the use of the separate config make more obvious for contributors.
  • Updating the GH Actions test workflow to trigger the tests on PHPUnit 10 with this configuration file.

Ref:


Note: while PHPUnit 11 has come out in the mean time as well, making the test suite compatible with that should wait for a while as we'll need PHPUnit 11.1 (expected April 5th) as a minimum and will need to make significant other changes to the tests, like splitting test classes based on what the tests cover, before we can start running the tests on PHPUnit 11.

As of PHPUnit 10, data providers are (again) expected to be `static` methods.

This updates the test suite to respect that.

Includes removing the use of `$this` from select data providers.

Refs:
* sebastianbergmann/phpunit@9caafe2
* sebastianbergmann/phpunit 5100
The PHPunit configuration file specification has undergone changes in PHPUnit 9.3, 10.0 and 10.1.

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.
* In PHPUnit 10.1, there is another change related to the code coverage configuration + the ability to fail builds on deprecations/warnings/notices is brought back.

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.

As this package is used in the CI pipeline for other packages, it is important for this package to be ready for new PHP releases _early_, so failing the test suite on deprecatios/notices and warnings is appropriate.

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.

This commit adds this dedicated configuration file for PHPUnit 10.1+.

Includes:
* Ignoring the new file for package archives.
* Allowing for a local override file.
* Adding scripts to the `composer.json` file to run the tests using this new configuration file and make the use of the separate config make more obvious for contributors.
* Updating the GH Actions `test` workflow to trigger the tests on PHPUnit 10 with this configuration file.

Ref:
* https://github.com/sebastianbergmann/phpunit/blob/main/ChangeLog-10.0.md#1000---2023-02-03
* sebastianbergmann/phpunit 5196
* sebastianbergmann/phpunit@fb6673f
@jrfnl jrfnl force-pushed the feature/tests-compatibility-with-phpunit-10 branch from 1e84fbb to 57f97e5 Compare March 27, 2024 15:04
Copy link
Member

@grogy grogy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you

@grogy grogy merged commit 5b45d93 into develop Apr 10, 2024
17 checks passed
@grogy grogy deleted the feature/tests-compatibility-with-phpunit-10 branch April 10, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants