-
Notifications
You must be signed in to change notification settings - Fork 70
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
Compatibility with PHPUnit 10 #232
Comments
hey @mgubala-edge1s thanks for getting in touch - support for PHP 8.1 should already exist as WP_Mock should work also in PHP 8.2 with the recent Mockery updates. As for PHPUnit 10, it's definitely under the radar but unfortunately can't give you an estimate for when support will be ready. |
@mgubala-edge1s @unfulvio-godaddy From what I can tell phpunit 10 is already supported. If you install phpunit 10 and then you install 10up/wp_mock it will install the version 0.4.2 of 10up/wp_mock. This happens because the requirements for this version where PHPUnit >= 7 and now the later versions lock to PHPUnit v9. I only noticed this now when I was trying to debug an issue with php stubs for phpstan. It seems that the php stubs loaded were from 10up/wp_mock but version 0.4.2 which had incorrect docblocks for add_action instead of the stubs I wanted to use that were https://github.com/php-stubs/wordpress-stubs. I was able to fix that in my phpstan config by pointing to the correct stubs so they get loaded before 10up/wp_mock runs. But regardless I am running the following versions of things (with phpunit 10 and do not seem to have any issues with 10up/wp_mock but I have not extensively used all the features, mostly just mocking functions, and expecting actions/filters)
I was able to get 1.0.0 installed with this in my composer.json and everything still appears to be working with phpunit 10.
|
To be honest I dont understand why composer wont install 1.0.0. The below extract from composer.json will install 0.4.2 "require-dev": {
"phpunit/phpunit": "^10",
"donatj/mock-webserver": "v2.7.1",
"wp-cli/wp-cli-bundle": "*",
"10up/wp_mock": "@dev"
} If I change to wp_mock "1.0.0" the composer update fails with the message .
Honestly semantic versioning means 10 exceeds ^9.6 and it should proceed.. |
@Narimm That is not how caret constraints work https://jubianchi.github.io/semver-check/#/^9.6/10.0.0 My solution above is still working above |
@tobeycodes solution seems the correct one for the time being We will eventually support PHPUnit 10 natively -- please check this PR for helping with 8.3 (which PHPUnit 10 supports as well): #237 |
That PR is looking good. It would be interesting if the project that consumes wp_mock can require php-stubs/wordpress-stubs that matches their WP version. I am not familiar enough to know if composer the best way to do that though. I did play around with PHP Unit 10 on the trunk version of wp_mock and there are definitely some breaking changes that need to be resolved in wp_mock. When running the test suite some things are failing. I am guessing that within my specific project these features are not being used so the issues go unoticed, so I would definitely use my solution above with caution. |
the stubs are only a dev dependency in WP Mock for PHPStan mostly so if you require WP_Mock, you are not including the stubs in your projects you can add those in your dev dependencies in your project's composer -- indeed there should be some compat work for achieving full PhpUnit 10 support |
What should I do to make WP_Mock working well with PHPUnit 10? |
Has there been any movement with PHPUnit 10? I'd like to use my current |
#237 was merged 10 months ago, what's left to do from there? |
Feature request
WP_Mock is not compatible with PHPUnit 10 / PHP 8.1.
Proposed solution
Make it compatible. Maybe You have it already in plans?
The text was updated successfully, but these errors were encountered: