WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 2 months ago

#53904 assigned task (blessed)

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: early 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() 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 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:

Change History (2)

#1 @hellofromTonya
3 months 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.


2 months ago

Note: See TracTickets for help on using tickets.