diff -u b/core/scripts/run-tests.sh b/core/scripts/run-tests.sh --- b/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Timer; use Drupal\Component\Uuid\Php; +use Drupal\Core\Composer\Composer; use Drupal\Core\Database\Database; use Drupal\Core\Site\Settings; use Drupal\Core\StreamWrapper\PublicStream; @@ -137,7 +138,7 @@ else { $phpunit_version = Version::id(); } -if (version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.2') >= 0 && version_compare($phpunit_version, '6.1') < 0) { +if (!Composer::upgradePHPUnitCheck($phpunit_version)) { 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); } @@ -465,10 +466,8 @@ // Detect if we're in the top-level process using the private 'execute-test' // argument. Determine if being run on drupal.org's testing infrastructure - // using the DCI_JobType environmental variable so we can update PHPUnit - // automatically. In all other cases if an update is necessary, an error - // message will be emitted telling the user to do the upgrade themselves. - if (!$args['execute-test'] && getenv('DCI_JobType') !== FALSE) { + // using the presence of 'drupaltestbot' in the database url. + if (!$args['execute-test'] && preg_match('/drupaltestbot/', $args['dburl'])) { // Update PHPUnit if needed and possible. There is a later check once the // autoloader is in place to ensure we're on the correct version. We need to // do this before the autoloader is in place to ensure that it is correct. diff -u b/core/tests/bootstrap.php b/core/tests/bootstrap.php --- b/core/tests/bootstrap.php +++ b/core/tests/bootstrap.php @@ -8,6 +8,7 @@ */ use Drupal\Component\Assertion\Handle; +use Drupal\Core\Composer\Composer; use PHPUnit\Runner\Version; /** @@ -157,7 +158,7 @@ else { $phpunit_version = Version::id(); } -if (version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.2') >= 0 && version_compare($phpunit_version, '6.1') < 0) { +if (!Composer::upgradePHPUnitCheck($phpunit_version)) { $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); only in patch2: unchanged: --- a/core/lib/Drupal/Core/Composer/Composer.php +++ b/core/lib/Drupal/Core/Composer/Composer.php @@ -162,13 +162,29 @@ public static function upgradePHPUnit(Event $event) { // If the PHP version is 7.2 or above and PHPUnit is less than version 6 // call the drupal-phpunit-upgrade script to upgrade PHPUnit. - if (version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.2') >= 0 && version_compare($phpunit_package->getVersion(), '6.1') < 0) { + if (!static::upgradePHPUnitCheck($phpunit_package->getVersion())) { $event->getComposer() ->getEventDispatcher() ->dispatchScript('drupal-phpunit-upgrade'); } } + /** + * Determines if PHPUnit needs to be upgraded. + * + * This method is located in this file because it is possible that it is + * called before the autoloader is available. + * + * @param string $phpunit_version + * The PHPUnit version string. + * + * @return bool + * TRUE if the PHPUnit needs to be upgraded, FALSE if not. + */ + public static function upgradePHPUnitCheck($phpunit_version) { + return !(version_compare(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '7.2') >= 0 && version_compare($phpunit_version, '6.1') < 0); + } + /** * Remove possibly problematic test files from vendored projects. *