WordPress.org

Make WordPress Core

Changeset 51812


Ignore:
Timestamp:
09/14/2021 06:47:46 PM (5 weeks ago)
Author:
hellofromTonya
Message:

Build/Test Tools: Improve messaging when PHPUnit Polyfills do not comply with version requirements.

Previously, two situations were taken in to account:

  1. The WP_TESTS_PHPUNIT_POLYFILLS_PATH constant is defined => just show a message about the version mismatch.
  2. The constant is not defined => show a message to run composer update. This message is intended for people trying to run the WP Core tests.

This could lead to an unclear situation for people trying to run plugin/theme integration tests without the new WP_TESTS_PHPUNIT_POLYFILLS_PATH constant being defined.

They could be shown the message to run composer update while if they would do so for their local install without adding the Polyfills, the message would still display the next time they would attempt to run the tests.

This commit:

  1. Provides more information about the PHPUnit Polyfills version detected vs the version expected.
  2. Shows a more specific message to guide users which have the WP_TESTS_PHPUNIT_POLYFILLS_PATH constant declared.
  3. Only shows the message to run composer update when the WP_RUN_CORE_TESTS constant is declared to prevent confusing people more.

Follow-up to [51598], [51810], [51811].

Props jrf, schlessera, hellofromTonya, jeherve, lucatume.
See #46149.

File:
1 edited

Legend:

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

    r51811 r51812  
    134134if ( class_exists( '\Yoast\PHPUnitPolyfills\Autoload' )
    135135    && ( defined( '\Yoast\PHPUnitPolyfills\Autoload::VERSION' ) === false
    136     || version_compare( \Yoast\PHPUnitPolyfills\Autoload::VERSION, $phpunit_polyfills_minimum_version, '<' ) )
     136    || version_compare( Yoast\PHPUnitPolyfills\Autoload::VERSION, $phpunit_polyfills_minimum_version, '<' ) )
    137137) {
    138138    printf(
    139         'Error: Version mismatch detected for the PHPUnit Polyfills. Please ensure that PHPUnit Polyfills %s or higher is loaded.' . PHP_EOL,
    140         $phpunit_polyfills_minimum_version
     139        'Error: Version mismatch detected for the PHPUnit Polyfills. Please ensure that PHPUnit Polyfills %s or higher is loaded. Found version: %s' . PHP_EOL,
     140        $phpunit_polyfills_minimum_version,
     141        defined( '\Yoast\PHPUnitPolyfills\Autoload::VERSION' ) ? Yoast\PHPUnitPolyfills\Autoload::VERSION : '1.0.0 or lower'
    141142    );
    142     if ( ! defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) {
     143    if ( defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) {
     144        printf(
     145            'Please ensure that the PHPUnit Polyfill install in "%s" is updated to version %s or higher.' . PHP_EOL,
     146            WP_TESTS_PHPUNIT_POLYFILLS_PATH,
     147            $phpunit_polyfills_minimum_version
     148        );
     149    } elseif ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
    143150        echo 'Please run `composer update` to install the latest version.' . PHP_EOL;
    144151    }
Note: See TracChangeset for help on using the changeset viewer.