From 8def694fe4c5df95f8e20e40389faf9cb92b6dca Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 7 Aug 2021 11:41:53 +0000 Subject: [PATCH] Build/Test Tools: Loosen the PHPUnit restriction. **composer.json**: Remove the PHPUnit dependency in favor of allowing the PHPUnit Polyfills library to manage the supported PHPUnit version. This automatically now widens the supported PHPUnit versions to 5.7.21 to 9.5.8 (current). Letting the PHPUnit Polyfills handle the version constraints for PHPUnit prevents potential version conflicts in the future, as well as allows WordPress to benefit straight away when a new PHPUnit version would be released and the PHPUnit Polyfills package adds support for that PHPUnit version. **Test Bootstrap** Update the supported version number for PHPUnit 5.x, as the minimum PHPUnit 5.x version supported by the PHPUnit Polyfills is PHPUnit 5.7.21, and remove the PHPUnit maximum. **.gitignore and svn:ignore:** Add the PHPUnit cache file to the list of files to be ignored. Since PHPUnit 8, PHPUnit has a built-in caching feature which creates a `.phpunit.result.cache` file. This file should not be committed. Follow-up to [40536], [40853], [44701], [51559-51573]. Props jrf. See #46149. git-svn-id: https://develop.svn.wordpress.org/trunk@51574 602fd350-edb4-49c9-b593-d223f7449a82 --- .gitignore | 1 + composer.json | 1 - tests/phpunit/includes/bootstrap.php | 6 +++--- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 8e37be718b..792c0c8ccb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ wp-tests-config.php .htaccess # Files and folders related to build/test tools +.phpunit.result.cache /phpunit.xml /.phpcs.xml /phpcs.xml diff --git a/composer.json b/composer.json index 804dfb090c..9da1af9769 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,6 @@ "squizlabs/php_codesniffer": "3.6.0", "wp-coding-standards/wpcs": "~2.3.0", "phpcompatibility/phpcompatibility-wp": "~2.1.2", - "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5", "yoast/phpunit-polyfills": "^1.0" }, "scripts": { diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index b557efd3d9..fed800ef3c 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -37,12 +37,12 @@ if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) $phpunit_version = tests_get_phpunit_version(); -if ( version_compare( $phpunit_version, '5.7', '<' ) || version_compare( $phpunit_version, '8.0', '>=' ) ) { +if ( version_compare( $phpunit_version, '5.7.21', '<' ) ) { printf( - "Error: Looks like you're using PHPUnit %s. WordPress requires at least PHPUnit 5.7 and is currently only compatible with PHPUnit up to 7.x.\n", + "Error: Looks like you're using PHPUnit %s. WordPress requires at least PHPUnit 5.7.21.\n", $phpunit_version ); - echo "Please use the latest PHPUnit version from the 7.x branch.\n"; + echo "Please use the latest PHPUnit version supported for the PHP version you are running the tests on.\n"; exit( 1 ); }