diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 209d253434..966db3aad0 100644 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -138,7 +138,7 @@ $phpunit_version = Version::id(); } if (version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.2') >= 0 && version_compare($phpunit_version, '6.1') < 0) { - echo "\nrun-tests.sh requires the PHPUnit testing framework version 6 or greater when running on PHP 7.2 or greater. Please use 'composer run-script drupal-phpunit-upgrade' to ensure that it is present.\n\n"; + simpletest_script_print_error("PHPUnit testing framework version 6 or greater is required when running on PHP 7.2 or greater. Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this."); exit(SIMPLETEST_SCRIPT_EXIT_FAILURE); } diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php index d376a06de3..429514179f 100644 --- a/core/tests/bootstrap.php +++ b/core/tests/bootstrap.php @@ -150,6 +150,19 @@ function drupal_phpunit_populate_class_loader() { // Do class loader population. drupal_phpunit_populate_class_loader(); +// Ensure we have the correct PHPUnit version for the version of PHP. +if (class_exists('\PHPUnit_Runner_Version')) { + $phpunit_version = \PHPUnit_Runner_Version::id(); +} +else { + $phpunit_version = Version::id(); +} +if (version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.2') >= 0 && version_compare($phpunit_version, '6.1') < 0) { + $message = "PHPUnit testing framework version 6 or greater is required when running on PHP 7.2 or greater. Run the command 'composer run-script drupal-phpunit-upgrade' in order to fix this."; + echo "\033[31m" . $message . "\n\033[0m"; + exit(1); +} + // Set sane locale settings, to ensure consistent string, dates, times and // numbers handling. // @see \Drupal\Core\DrupalKernel::bootEnvironment() @@ -168,17 +181,6 @@ function drupal_phpunit_populate_class_loader() { // not turn runtime assertions on if they weren't on already. Handle::register(); -// Ensure we have the correct PHPUnit version for the version of PHP. -if (class_exists('\PHPUnit_Runner_Version')) { - $phpunit_version = \PHPUnit_Runner_Version::id(); -} -else { - $phpunit_version = Version::id(); -} -if (version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.2') >= 0 && version_compare($phpunit_version, '6.1') < 0) { - echo "\nTesting Drupal requires the PHPUnit testing framework version 6 or greater when running on PHP 7.2 or greater. Please use 'composer run-script drupal-phpunit-upgrade' to ensure that it is present.\n\n"; - exit(1); -} // PHPUnit 4 to PHPUnit 6 bridge. Tests written for PHPUnit 4 need to work on // PHPUnit 6 with a minimum of fuss. if (version_compare($phpunit_version, '6.1', '>=')) {