diff --git a/core/modules/system/system.install b/core/modules/system/system.install index c6851ef..05fa4fc 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -186,7 +186,6 @@ function system_requirements($phase) { ]; } - $is_test_site = drupal_valid_test_ua() || getenv('DRUPAL_DEV_SITE_PATH'); if (version_compare($phpversion, DRUPAL_MINIMUM_UPDATE_PHP) < 0) { $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_UPDATE_PHP]); $requirements['php']['severity'] = REQUIREMENT_ERROR; @@ -201,7 +200,7 @@ function system_requirements($phase) { $requirements['php']['severity'] = REQUIREMENT_WARNING; } // Allow test installations of Drupal on older PHP versions. - elseif (!$is_test_site) { + elseif (!drupal_valid_test_ua()) { $requirements['php']['description'] = t('Your PHP installation is too old. Drupal requires at least PHP %version.', ['%version' => DRUPAL_MINIMUM_PHP]); $requirements['php']['severity'] = REQUIREMENT_ERROR; // If PHP is old, it's not safe to continue with the requirements check. diff --git a/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php b/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php index 5622aa2..9333bba 100644 --- a/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php +++ b/core/tests/Drupal/Tests/Core/Command/QuickStartTest.php @@ -83,6 +83,10 @@ public function tearDown() { * Tests the quick-start command. */ public function testQuickStartCommand() { + if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) { + $this->markTestSkipped(); + } + // Install a site using the standard profile to ensure the one time login // link generation works. @@ -133,9 +137,47 @@ public function testQuickStartCommand() { } /** + * Tests that the installer throws a requirement error on older PHP versions. + */ + public function testPhpRequirement() { + if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) >= 0) { + $this->markTestSkipped(); + } + + $install_command = [ + $this->php, + 'core/scripts/drupal', + 'quick-start', + 'standard', + "--site-name='Test site {$this->testDb->getDatabasePrefix()}'", + '--suppress-login', + ]; + $process = new Process($install_command, NULL, ['DRUPAL_DEV_SITE_PATH' => $this->testDb->getTestSitePath()]); + $process->inheritEnvironmentVariables(); + $process->setTimeout(500); + $process->start(); + while ($process->isRunning()) { + // Wait for more output. + sleep(1); + } + + $error_output = $process->getErrorOutput(); + $this->assertContains('Your PHP installation is too old.', $error_output); + $this->assertContains('Drupal requires at least PHP', $error_output); + $this->assertContains(DRUPAL_MINIMUM_PHP, $error_output); + + // Stop the web server. + $process->stop(); + } + + /** * Tests the quick-start commands. */ public function testQuickStartInstallAndServerCommands() { + if (version_compare(phpversion(), DRUPAL_MINIMUM_PHP) < 0) { + $this->markTestSkipped(); + } + // Install a site. $install_command = [ $this->php, @@ -290,3 +332,7 @@ protected function fileUnmanagedDeleteRecursive($path, $callback = NULL) { } } + +if (!defined('DRUPAL_MINIMUM_PHP')) { + define('DRUPAL_MINIMUM_PHP', '7.0.0'); +}