[wp-trac] [WordPress Trac] #46149: PHPUnit 8.x support

WordPress Trac noreply at wordpress.org
Wed Aug 19 08:41:11 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:28 dd32]:
 > I suspect the best option might be to shim the functions in question.

 I went ahead and put something together that does just that, it's not
 super pretty, but it does work on PHP 5.6 -> 8.0 with PHPUnit 5 -> 9.

 Most importantly, it introduces a way to shim functionality from newer
 PHPUnits for older PHPUnit versions, so the tests can immediately use the
 new functionality from PHPUnit 9 - it just has to include a compat method
 for the older versions.

 **Unfortunately** it did require ceasing using the `setUp()` (and friends)
 methods directly, as there's simply no way to have those functions defined
 AND work on all current supported PHPs.
 For now, I've simply prefixed those methods with an underscore, we do have
 custom `wpSetUpBeforeClass()` and `wpTearDownAfterClass()` methods though,
 we could probably do the same for the `setUp()`/etc.

 I think this will affect plugins in some way or another, but if they're
 affected they'd have had to change their testing to work with PHP8 anyway.

 My primary goal here was to get unit testing for PHP 5.6-8.0 running for
 core, so that there was a possibility to actually see the PHP 8 Unit test
 status..

 To reduce the diff size for review, all of the code changes to the tests
 are done through a bash script, mostly based on @jrf's PR, only the
 changes to the test runner framework is in the PR as a code change.

 If you want to see the complete changes to the tests, you can run the
 `./tools/migrate-test-syntax.sh` script locally or look around line 200 of
 the Travis tests for a 16,000 line diff.

 Here's the [https://github.com/WordPress/wordpress-develop/pull/489 PR]
 and hopefully, all the Travis tests will pass.. except for PHP8.. which
 well you'll see :)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46149#comment:35>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list