[wp-trac] [WordPress Trac] #53904: Add command-line notifications for test fixture method void return type breaking changes

WordPress Trac noreply at wordpress.org
Mon Aug 9 20:04:09 UTC 2021


#53904: Add command-line notifications for test fixture method void return type
breaking changes
------------------------------+-----------------------------
 Reporter:  hellofromTonya    |      Owner:  (none)
     Type:  task (blessed)    |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:  early
  Focuses:                    |
------------------------------+-----------------------------
 Related to: #46149

 This ticket proposes to add command-line notification messages to help
 extenders by:

 - making them aware of the fixture method return type and renaming
 - providing them guidance on how to upgrade their tests by including a
 link to the Dev Note and possibly the docs

 == Context

 PHPUnit 8.0.0 changed the fixture method return type (changed to `void`)
 which broke backwards-compatibility. To handle the `void` return type, the
 fixture methods were renamed to use snake_care naming (see #46149
 changeset [51568]). This change affects the following fixture methods:

 - `setUpBeforeClass()` became `set_up_before_class()`
 - `setUp()` became `set_up()`
 - `tearDown()` became `tear_down()`
 - `tearDownAfterClass()` became `tear_down_after_class()`
 - No change was made to `wpSetUpBeforeClass()` or `wpTearDownAfterClass()`

 This breaking change is unavoidable. However, steps can be taken to help
 extenders upgrade their tests through the 5.9 release cycle.

 == The Problem

 Fatal error in tests when extenders:

 - are using WordPress' test case(s)
 - running against trunk and/or in the future >= WordPress 5.9
 - any of test class uses the original fixture methods, i.e. rather than
 the snake_case names
 - and running PHPUnit 8+

 Unexpected behavior will happen (non-fatal error) when:
 - all of the above
 - except running with less than PHP 8.0.0

 Why? The native PHPUnit fixture methods would be invoked instead of the
 WordPress's fixture methods.

 == Proposal

 In a [https://www.youtube.com/watch?v=SAtiKaUwLU4&t=10224s live working
 session] with @johnbillion, @sergeybiryukov, @jrf, and me, we discussed
 adding the following command line notifications:

 - Add a notification to the test bootstrap
 - Capture the fixture method return type fatal error through the test
 listener and provide a more verbose, informative, and guiding message

 == Reference

 Listen or watch the discussions in a live working session:

 - [https://www.youtube.com/watch?v=SAtiKaUwLU4&t=7656s Handling `void`
 return type in fixture methods with `snake_case`]
 - [https://www.youtube.com/watch?v=SAtiKaUwLU4&t=8453s Discussion of
 implementing snake_case]
 - [https://www.youtube.com/watch?v=SAtiKaUwLU4&t=8698s Breaking change for
 extenders discussion]
 - [https://www.youtube.com/watch?v=SAtiKaUwLU4&t=10224s How to help
 extenders]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53904>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list