function UpdatePathTestBase::installDrupal

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::installDrupal()
  2. 8.9.x core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::installDrupal()
  3. 11.x core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::installDrupal()

Overrides BrowserTestBase::installDrupal() for update testing.

The main difference in this method is that rather than performing the installation via the installer, a database is loaded. Additional work is then needed to set various things such as the config directories and the container that would normally be done via the installer.

Overrides BrowserTestBase::installDrupal

File

core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php, line 106

Class

UpdatePathTestBase
Provides a base class for writing an update test.

Namespace

Drupal\FunctionalTests\Update

Code

public function installDrupal() {
  // Set the update URL. This must be set here rather than in
  // self::__construct() or the old URL generator will leak additional test
  // sites. Additionally, we need to prevent the path alias processor from
  // running because we might not have a working alias system before running
  // the updates.
  $this->updateUrl = Url::fromRoute('system.db_update', [], [
    'path_processing' => FALSE,
  ]);
  $this->initUserSession();
  $this->prepareSettings();
  $this->doInstall();
  $this->initSettings();
  $request = Request::createFromGlobals();
  $container = $this->initKernel($request);
  $this->initConfig($container);
  // Add the config directories to settings.php.
  $sync_directory = Settings::get('config_sync_directory');
  \Drupal::service('file_system')->prepareDirectory($sync_directory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
  // Ensure the default temp directory exist and is writable. The configured
  // temp directory may be removed during update.
  \Drupal::service('file_system')->prepareDirectory($this->tempFilesDirectory, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
  // Set the container. parent::rebuildAll() would normally do this, but this
  // not safe to do here, because the database has not been updated yet.
  $this->container = \Drupal::getContainer();
  $this->replaceUser1();
  require_once $this->root . '/core/includes/update.inc';
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.