[wp-trac] [WordPress Trac] #46149: PHPUnit 8.x support
WordPress Trac
noreply at wordpress.org
Thu Aug 20 06:40:38 UTC 2020
#46149: PHPUnit 8.x support
--------------------------------------------+-----------------------
Reporter: SergeyBiryukov | Owner: netweb
Type: task (blessed) | Status: assigned
Priority: high | Milestone: 5.6
Component: Build/Test Tools | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests early | Focuses:
--------------------------------------------+-----------------------
Comment (by dd32):
Replying to [comment:32 jrf]:
> 1. It really isn't as straight forward as outlined in the comments above
and I say so based on both my experience with other test code bases as
well as on the work I did for this ticket.
@jrf I'd like to bow down to you and agree with you. I apologise for
doubting you. It's not realistic to follow what I outlined above. It
works, but it's not worth it, and it's a support burden that can't be
carried forward.
I've taken my above PR and forked it into a [https://github.com/WordPress
/wordpress-develop/pull/491 new PR 491] which does two things, which I
think is a reasonable middleground
- Standardises on PHPUnit8/9 assert calls, requires PHP 7.2+ to run.
- Includes a bash script for use on Travis to remove the void return type
hinting so that Travis can still run the Unit tests for PHP 5.6, 7.0, and
7.1.
There are two bash scripts included, one of which will be required to be
bundled for Travis:
- [https://github.com/WordPress/wordpress-develop/pull/491/files#diff-
d7603d0e714f4f8b6def3e3d72e9c8ea tools/migrate-test-syntax.sh] Responsible
for doing some automated changes to the codebase that's needed for
PHPUnit8/9 support - @jrf did a better job than this script in
[https://github.com/WordPress/wordpress-develop/pull/484 PR484] but this
let me test that PHP8 support was working without making the PR diff huge.
- [https://github.com/WordPress/wordpress-develop/pull/491/files#diff-
0cb7de3f4326e9eaded3a7053cf7c170 tools/tests-old-php.sh] It's responsible
for removing the PHP 7.2+ syntax (Right now, just the void return type
hinting) so that the tests will run on PHP 5.6-7.1 with PHPUnit 5-6. This
one is going to be needed on Travis, It could be done just be done inline
in `.travis.yml` but I'm assuming that we might end up adding other things
when PHPUnit 10 comes out next year, so it seems worth while including it
separately, which also allows developers to run it locally if needed.
The PHPUnit Compat traits that I've got in there are super minimal and
just pass it through to other assertion methods that should exist. I did
it slightly different to PR484 which makes it far easier and simpler as we
don't have to use matching function definitions, nor check if the native
function exists. PR484 has better PHPDocs though.
There's a bunch of other cleanups that can be done, but I didn't look
into, such as using the PHPUnit namespaces and the SpeedTrap changes.
[https://github.com/WordPress/wordpress-develop/runs/1006340826 all of the
unit tests run] with only PHP8 failing due to some Core changes needed and
some test alterations that I couldn't easily automate.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46149#comment:38>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list