function RecipeQuickStartTest::testQuickStartRecipeCommand
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/Recipe/RecipeQuickStartTest.php \Drupal\Tests\Core\Recipe\RecipeQuickStartTest::testQuickStartRecipeCommand()
Tests the quick-start command with a recipe.
File
-
core/
tests/ Drupal/ Tests/ Core/ Recipe/ RecipeQuickStartTest.php, line 87
Class
- RecipeQuickStartTest
- Tests the quick-start command with recipes.
Namespace
Drupal\Tests\Core\RecipeCode
public function testQuickStartRecipeCommand() : void {
$sqlite = (string) (new \PDO('sqlite::memory:'))->query('select sqlite_version()')
->fetch()[0];
if (version_compare($sqlite, Tasks::SQLITE_MINIMUM_VERSION) < 0) {
$this->markTestSkipped();
}
// Install a site using the standard recipe to ensure the one time login
// link generation works.
$script = $this->root . '/core/scripts/drupal';
$install_command = [
$this->php,
$script,
'quick-start',
'core/recipes/standard',
"--site-name='Test site {$this->testDb->getDatabasePrefix()}'",
'--suppress-login',
];
$this->assertFileExists($script, "Install script is found in {$script}");
$process = new Process($install_command, NULL, [
'DRUPAL_DEV_SITE_PATH' => $this->testDb
->getTestSitePath(),
]);
$process->setTimeout(500);
$process->start();
$guzzle = new Client();
$port = FALSE;
$process->waitUntil(function ($type, $output) use (&$port) {
if (preg_match('/127.0.0.1:(\\d+)/', $output, $match)) {
$port = $match[1];
return TRUE;
}
});
// The progress bar uses STDERR to write messages.
$this->assertStringContainsString('Congratulations, you installed Drupal!', $process->getErrorOutput());
// Ensure the command does not trigger any PHP deprecations.
$this->assertStringNotContainsStringIgnoringCase('deprecated', $process->getErrorOutput());
$this->assertNotFalse($port, "Web server running on port {$port}");
// Give the server a couple of seconds to be ready.
sleep(2);
$this->assertStringContainsString("127.0.0.1:{$port}/user/reset/1/", $process->getOutput());
// Generate a cookie so we can make a request against the installed site.
define('DRUPAL_TEST_IN_CHILD_SITE', FALSE);
chmod($this->root . '/' . $this->testDb
->getTestSitePath(), 0755);
$cookieJar = CookieJar::fromArray([
'SIMPLETEST_USER_AGENT' => drupal_generate_test_ua($this->testDb
->getDatabasePrefix()),
], '127.0.0.1');
$response = $guzzle->get('http://127.0.0.1:' . $port, [
'cookies' => $cookieJar,
]);
$content = (string) $response->getBody();
$this->assertStringContainsString('Test site ' . $this->testDb
->getDatabasePrefix(), $content);
// Test content from Standard front page.
$this->assertStringContainsString('Congratulations and welcome to the Drupal community.', $content);
// Stop the web server.
$process->stop();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.