Make WordPress Core


Ignore:
Timestamp:
11/05/2026 03:36:34 PM (7 days ago)
Author:
lancewillett
Message:

Build/Test Tools: Only declare the default group filter where PHPUnit has test listeners.

[65251] declared WP_PHPUnit_Default_Group_Filter as a PHPUnit\Framework\TestListener for every PHPUnit version from 6.0. PHPUnit 10 removed that interface, so loading the test bootstrap with PHPUnit 10 or later failed before any test ran. This broke test suites that load the core test library with newer PHPUnit versions, such as the WordPress.org unit tests.

The listener is now declared only when the interface exists. PHPUnit 9 and earlier are unchanged. PHPUnit 10 and later do not support listeners.

Follow-up to [65251].

Developed in: ​https://github.com/WordPress/wordpress-develop/pull/15508

Props ekamran.
See #34185.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/bootstrap.php

    r65251 r65276  
    581581}
    582582
     583// PHPUnit 10 and later have no TestListener interface, so the filter is not declared there.
    583584if ( version_compare( tests_get_phpunit_version(), '6.0', '<' ) ) {
    584585        class WP_PHPUnit_Default_Group_Filter implements PHPUnit_Framework_TestListener {
    … …  
    587588                }
    588589        }
    589 } else {
     590} elseif ( interface_exists( 'PHPUnit\Framework\TestListener' ) ) {
    590591        class WP_PHPUnit_Default_Group_Filter implements PHPUnit\Framework\TestListener {
    591592                use Yoast\PHPUnitPolyfills\TestListeners\TestListenerDefaultImplementation, WP_PHPUnit_Default_Group_Filter_Methods {
Note: See TracChangeset for help on using the changeset viewer.