protected function UpdateTestBase::createTestSite in Automatic Updates 8.2
Uses our already-installed dependencies to build a test site to update.
Parameters
string $template: The template project from which to build the test site. Can be 'drupal/recommended-project' or 'drupal/legacy-project'.
1 call to UpdateTestBase::createTestSite()
- CoreUpdateTest::createTestSite in tests/
src/ Build/ CoreUpdateTest.php - Uses our already-installed dependencies to build a test site to update.
1 method overrides UpdateTestBase::createTestSite()
- CoreUpdateTest::createTestSite in tests/
src/ Build/ CoreUpdateTest.php - Uses our already-installed dependencies to build a test site to update.
File
- tests/
src/ Build/ UpdateTestBase.php, line 147
Class
- UpdateTestBase
- Base class for tests that perform in-place updates.
Namespace
Drupal\Tests\automatic_updates\BuildCode
protected function createTestSite(string $template) : void {
// Create the test site using one of the core project templates, but don't
// install dependencies just yet.
$template_dir = implode(DIRECTORY_SEPARATOR, [
$this
->getDrupalRoot(),
'composer',
'Template',
]);
$recommended_template = $this
->createPathRepository($template_dir . DIRECTORY_SEPARATOR . 'RecommendedProject');
$legacy_template = $this
->createPathRepository($template_dir . DIRECTORY_SEPARATOR . 'LegacyProject');
$dir = $this
->getWorkspaceDirectory();
$command = sprintf("composer create-project %s %s --no-install --stability dev --repository '%s' --repository '%s'", $template, $dir, Json::encode($recommended_template), Json::encode($legacy_template));
$this
->executeCommand($command);
$this
->assertCommandSuccessful();
$composer = $dir . DIRECTORY_SEPARATOR . 'composer.json';
$data = $this
->readJson($composer);
// Allow the test to configure the test site as necessary.
$data = $this
->getInitialConfiguration($data);
// We need to know the path of the web root, relative to the project root,
// in order to install Drupal or visit the test site at all. Luckily, both
// template projects define this because the scaffold plugin needs to know
// it as well.
// @see ::visit()
// @see ::formLogin()
// @see ::installQuickStart()
$this->webRoot = $data['extra']['drupal-scaffold']['locations']['web-root'];
// Update the test site's composer.json and install dependencies.
$this
->writeJson($composer, $data);
$this
->executeCommand('composer install --no-dev');
$this
->assertCommandSuccessful();
}