Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport support for the
AssertObjectProperty
polyfill
PHPUnit 10.1.0 introduced two new assertions - `assertObjectHasProperty()` and `assertObjectNotHasProperty()` - to replace the `assertObjectHasAttribute() and `assertObjectNotHasAttribute()` methods, which were deprecated in PHPUnit 9.6.0 and removed in PHPUnit 10.0.0. These two new assertions have since been backported to PHPUnit 9.x in PHPUnit 9.6.11 to allow for getting rid of the deprecation notice and making preparing for PHPUnit 10 more smooth. The PHPUnit Polyfills have followed suit and the 1.1.0 release contains polyfills for the backported `assertObjectHasProperty()` and `assertObjectNotHasProperty()` methods. For the WP Test Utils package, this caused an interesting conundrum: * WP 6.4 - which enforces the use of PHPUnit Polyfills 1.1.0+ - will have the new polyfills available. * WP 5.9 - 6.3 will have the new polyfills available _if the test dependencies are updated and PHPUnit Polyfills 1.1.0+ is used_. * WP 5.2 - 5.9 versions, which include the backports, will **not** have the new polyfills available. * WP 5.2 - 5.9 versions, which **don't** include the backports, will **not** have the new polyfills available. * WP < 5.2 will **not** have the new polyfills available. Previously the WP Test Utils would have two test cases available for integration tests: * One for use with WP 5.9+ and with WP versions < 5.9 which included the backports. * One for use with WP < 5.2 and with WP versions < 5.9 which do not include the backports. To solve the conundrum, this commit: * Updates the minimum version of the PHPUnit Polyfills to 1.1.0. * Add the new polyfill to the test case which is used for WP < 5..2 and for WP versions < 5.9 which do not include the backports. * Introduces a third test case for integration tests against WP 5.2 - 5.8 versions, which _do_ include the backports, but not the new polyfill. While this third polyfill might technically not be needed, I've seen too many issues with traits colliding on older PHP versions to be willing to take that risk. * Updates the autoloader to load the correct test case. This should ensure that the new polyfill is available in all cases.
- Loading branch information