Make WordPress Core

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's profile hellofromTonya Owned by: hellofromtonya's profile hellofromTonya
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: php8
Focuses: Cc:


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


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.


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


Listen or watch the discussions in a live working session:

Change History (3)

#1 @hellofromTonya
3 years ago

  • Keywords php8 added
  • Milestone changed from Awaiting Review to 5.9
  • Owner set to hellofromTonya
  • Status changed from new to assigned

This ticket was mentioned in Slack in #core-test by hellofromtonya. View the logs.

3 years ago

#3 @hellofromTonya
3 years ago

  • Keywords early removed
  • Resolution set to fixed
  • Status changed from assigned to closed

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.

Note: See TracTickets for help on using tickets.