You are here

public function QuickStartTest::testPhpRequirement in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/Core/Command/QuickStartTest.php \Drupal\Tests\Core\Command\QuickStartTest::testPhpRequirement()

Tests that the installer throws a requirement error on older PHP versions.

File

core/tests/Drupal/Tests/Core/Command/QuickStartTest.php, line 142

Class

QuickStartTest
Tests the quick-start commands.

Namespace

Drupal\Tests\Core\Command

Code

public function testPhpRequirement() {
  if (version_compare(phpversion(), DRUPAL_MINIMUM_SUPPORTED_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_SUPPORTED_PHP, $error_output);

  // Stop the web server.
  $process
    ->stop();
}