Make WordPress Core


Ignore:
Timestamp:
09/14/2021 06:32:39 PM (3 years ago)
Author:
hellofromTonya
Message:

Build/Test Tools: Make WP_TESTS_PHPUNIT_POLYFILLS_PATH more flexible.

The constant WP_TESTS_PHPUNIT_POLYFILLS_PATH is intended to contain the path to the root directory of the PHPUnit Polyfills library without trailing slash.

The code already took into account that the value could potentially include a trailing slash.

Now it will also take into account if it is accidentally set to point to the autoload file instead of the path.

Follow-up to [51598].

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

File:
1 edited

Legend:

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

    r51669 r51810  
    8787            && '' !== WP_TESTS_PHPUNIT_POLYFILLS_PATH
    8888        ) {
    89             $phpunit_polyfills_path = rtrim( $phpunit_polyfills_path, '/\\' );
    90             $phpunit_polyfills_path = realpath( $phpunit_polyfills_path . '/phpunitpolyfills-autoload.php' );
     89            // Be tolerant to the path being provided including the filename.
     90            if ( substr( $phpunit_polyfills_path, -29 ) !== 'phpunitpolyfills-autoload.php' ) {
     91                $phpunit_polyfills_path = rtrim( $phpunit_polyfills_path, '/\\' );
     92                $phpunit_polyfills_path = $phpunit_polyfills_path . '/phpunitpolyfills-autoload.php';
     93            }
     94
     95            $phpunit_polyfills_path = realpath( $phpunit_polyfills_path );
    9196            if ( false !== $phpunit_polyfills_path ) {
    9297                $phpunit_polyfills_autoloader = $phpunit_polyfills_path;
Note: See TracChangeset for help on using the changeset viewer.