WordPress.org

Make WordPress Core

Changeset 51598 for trunk/composer.json


Ignore:
Timestamp:
08/10/2021 09:13:38 PM (4 months ago)
Author:
SergeyBiryukov
Message:

Build/Test Tools: Make the polyfills loading more flexible.

The PHPUnit Polyfills are, since [51559], a required dependency for the WP test suite and, by extension, for plugin/theme integration test suites which are based on and use (parts of) the WP core test suite.

However, plugin/theme integration test suites may not use a full WordPress installation.

This commit:

  • Removes the presumption that a full WP install, including vendor directory, will be available when the test bootstrap.php file is run.
  • Makes the loading of the PHPUnit Polyfills autoload file more flexible by:
    • Checking if the autoload class contained within the autoload file is already available before attempting to load the file.
      This allows for plugin/theme integration test suites to load the phpunitpolyfills-autoload.php file from any location, as long as it is loaded before the WP core test bootstrap.php file is run.
    • Allowing for the path to an arbitrary installation location for the PHPUnit Polyfills to be passed as a constant.
      As long as the provided location is a valid file path and the phpunitpolyfills-autoload.php file exists in the provided location, that file will be loaded.
      The constant can be declared in a plugin/theme integration test suite native test bootstrap file, or in the wp-tests-config.php file, or even in a phpunit.xml[.dist] file via <php><const name="WP_TESTS_PHPUNIT_POLYFILLS_PATH" value="path/to/yoast/phpunit-polyfills"/></php>.
  • Adds a version check for the PHPUnit Polyfills to prevent a mismatch between the version of the package expected by WordPress and the version used by plugins/themes.
    The version this checks for should be in line with the minimum version requirement for the PHPUnit Polyfills as declared in the composer.json file.
    This version number should only be updated when new features added in later PHPUnit Polyfills releases are actually used in the WP core test suite.
  • Adds appropriate error messages for every possible error condition.
  • Upgrades the PHPUnit Polyfills to version 1.0.1, which now includes a version constant.

Follow-up to [51559-51577].

Props jrf, hellofromTonya, swissspidy, jeherve, thomasplevy, SergeyBiryukov.
See #46149.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/composer.json

    r51574 r51598  
    1818        "wp-coding-standards/wpcs": "~2.3.0",
    1919        "phpcompatibility/phpcompatibility-wp": "~2.1.2",
    20         "yoast/phpunit-polyfills": "^1.0"
     20        "yoast/phpunit-polyfills": "^1.0.1"
    2121    },
    2222    "scripts": {
Note: See TracChangeset for help on using the changeset viewer.