[wp-trac] [WordPress Trac] #59150: Tests: update for PHPUnit Polyfills 1.1.0
WordPress Trac
noreply at wordpress.org
Sat Aug 19 16:05:46 UTC 2023
#59150: Tests: update for PHPUnit Polyfills 1.1.0
------------------------------+-----------------------------
Reporter: jrf | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Build/Test Tools | Version: trunk
Severity: normal | Keywords:
Focuses: |
------------------------------+-----------------------------
== Background
PHPUnit deprecated the `assertObjectHasAttribute()` and
`assertObjectNotHasAttribute()` methods in
[https://github.com/sebastianbergmann/phpunit/blob/9.6/ChangeLog-9.6.md#961
---2023-02-03 PHPUnit 9.6.1], which means that there are currently a
number of tests which show deprecation notices in the logs because of
this.
By popular request, these methods were brought back, though renamed as
`assertObjectHasProperty()` and `assertObjectNotHasProperty()` (to prevent
confusion with PHP 8.0 attributes), in
[https://github.com/sebastianbergmann/phpunit/blob/10.1.3/ChangeLog-10.1.md#1010
---2023-04-14 PHPUnit 10.1.0].
This meant that users which cannot upgrade (yet) to PHPUnit 10.1+ would
always have deprecation notices for these methods without recourse.
So, after much discussion, PHPUnit has now backported the new methods to
[https://github.com/sebastianbergmann/phpunit/blob/9.6/ChangeLog-9.6.md#9611
---2023-08-19 PHPUnit 9.6.11], leaving just the 10.0.x series with a
deprecation notice and no recourse.
== What does this mean for WordPress ?
WordPress uses the [https://github.com/Yoast/PHPUnit-Polyfills PHPUnit
Polyfills] to be able to write tests for the "latest" version of PHPUnit
(well, almost), with the Polyfills taking care of polyfilling any new
PHPUnit methods on older PHPUnit versions.
The PHPUnit Polyfills 1.x series supports PHPUnit 4.x - 9.x.
The PHPUnit Polyfills 2.x series supports PHPUnit 5.x - 10.x.
Due to other, unrelated, feature removals in PHPUnit 10, WordPress is
currently still limited to running against PHPUnit 6.x - 9.x with PHPUnit
Polyfills 1.x, while the new methods were only included in PHPUnit
Polyfills 2.0.0+ (as they were introduced in PHPUnit 10.x).
But... as the `assertObjectHasProperty()` and
`assertObjectNotHasProperty()` methods have now been backported to PHPUnit
9.x, the PHPUnit Polyfills will now polyfill these methods in the 1.x
series as well, which means that by upgrading to the
[https://github.com/Yoast/PHPUnit-Polyfills/releases/tag/1.1.0 latest
PHPUnit Polyfills release - 1.1.0 -], we can get rid of the deprecation
notices related to the use of the `assertObjectHasAttribute()` and
`assertObjectNotHasAttribute()` methods.
== Implications
I have a patch ready for this and will pull it to GitHub in a moment.
Amongst other things, the patch updates the minimum supported PHPUnit
Polyfills version in the `tests/phpunit/includes/bootstrap.php` to
`1.1.0`.
This ''could'' have implications for plugins/themes running integration
tests with WordPress if they have set their PHPUnit Polyfills dependency
to a fixed version or have a too strict version constraint (limiting the
PHPUnit Polyfills to the 1.0.x series).
The solution for those plugins/themes is to update their version
constraints for the PHPUnit Polyfills to allow for the 1.1.x series.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/59150>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list