Opened 3 years ago
Closed 3 years ago
#53904 closed task (blessed) (fixed)
Add command-line notifications for test fixture method void return type breaking changes
Reported by: | hellofromTonya | Owned by: | hellofromTonya |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Build/Test Tools | Keywords: | php8 |
Focuses: | Cc: |
Description
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()
becameset_up_before_class()
setUp()
becameset_up()
tearDown()
becametear_down()
tearDownAfterClass()
becametear_down_after_class()
- No change was made to
wpSetUpBeforeClass()
orwpTearDownAfterClass()
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 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:
Removing
early
. I believe this has been resolved already in #46149 as well as directly in the PHPUnit Polyfills package. Closing as fixed. Please reopen if more improvements can be made.