[wp-trac] [WordPress Trac] #53911: Test modernization backwards-compatibility backports to help extenders with WordPress cross-version testing

WordPress Trac noreply at wordpress.org
Thu Aug 12 22:23:06 UTC 2021


#53911: Test modernization backwards-compatibility backports to help extenders with
WordPress cross-version testing
------------------------------+--------------------------
 Reporter:  hellofromTonya    |       Owner:  johnbillion
     Type:  task (blessed)    |      Status:  assigned
 Priority:  normal            |   Milestone:  5.9
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
------------------------------+--------------------------

Comment (by jrf):

 I've done a careful assessment of what is feasible and necessary for the
 backports and @hellofromTonya and me have discussed this.

 As things are, we'd like to propose the following for the backports:

 == WordPress 5.2 - 5.8

 - Add PHPUnit Polyfills as a Composer dependency.
 - Add the Polyfill traits to the `WP_UnitTestCase`.
 - Add the loading of the Polyfill autoloader to the bootstrap in the same
 way as done for WP 5.9.
 - Add `set_up()`, `tear_down()` etc wrappers to the `WP_UnitTestCase`
 class. These fall through to the camelCase methods in the
 `WP_UnitTestCase_Base` class.
 - Add `set_up()`, `tear_down()` etc wrappers to the other WP native
 TestCases within the `tests/phpunit/includes` directory.

 == WordPress 5.1 and lower

 - Backport just and only the fixture method wrappers and nothing else.

 It is not an option to introduce the PHPUnit Polyfills to older WP
 versions as the minimum PHP requirement for the Polyfills in PHP 5.4, due
 to the use of traits.

 Integration test suites for plugins/themes which still support older WP
 versions, but have a minimum PHP requirement of PHP 5.4, can still
 introduce the Polyfills in their own test suite for those older WP
 versions.

 At this point it is undecided ''how far back'' to backport the fixture
 method wrappers.

 == Impact Assessment

 ➕ Allows for (security) tests backported for WP Core itself to work
 without changes using the features as per WP 5.9 for WP 5.2 to 5.8. For
 older WP versions, some assertion/expectation method calls ''may'' need to
 be switched out for their "old" name.
 ➕ Allows integration tests to switch completely to snake_case fixture
 method names.
 ➕ Allows integration tests to use PHPUnit 9.x assertion and expectation
 methods via the Polyfills for WP 5.2 and higher. When the test suite would
 also need to run in combination with older WP versions, the Polyfills can
 still be used, as long as the tests are run on PHP 5.4 or higher.
 ➕ It prevents breaking integration test suites which haven't updated to
 the "WP 5.9 way" yet.

 ➖ Still limits running of the tests on WP < 5.9 to PHPUnit 5.x - 7.x.
 ➖ With as a consequence that integration tests will need to do some
 PHPUnit version juggling, probably via Composer, in their CI.

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


More information about the wp-trac mailing list