You are here

protected function UpdateTestBase::setUp in Drupal 8

Same name in this branch
  1. 8 core/modules/update/src/Tests/UpdateTestBase.php \Drupal\update\Tests\UpdateTestBase::setUp()
  2. 8 core/modules/update/tests/src/Functional/UpdateTestBase.php \Drupal\Tests\update\Functional\UpdateTestBase::setUp()

Sets up a Drupal site for running functional and integration tests.

Installs Drupal with the installation profile specified in \Drupal\simpletest\WebTestBase::$profile into the prefixed database.

Afterwards, installs any additional modules specified in the static \Drupal\simpletest\WebTestBase::$modules property of each class in the class hierarchy.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Overrides WebTestBase::setUp

File

core/modules/update/src/Tests/UpdateTestBase.php, line 34

Class

UpdateTestBase
Defines some shared functions used by all update tests.

Namespace

Drupal\update\Tests

Code

protected function setUp() {
  parent::setUp();

  // Change the root path which Update Manager uses to install and update
  // projects to be inside the testing site directory. See
  // \Drupal\update\UpdateRootFactory::get() for equivalent changes to the
  // test child site.
  $request = \Drupal::request();
  $update_root = $this->container
    ->get('update.root') . '/' . DrupalKernel::findSitePath($request);
  $this->container
    ->set('update.root', $update_root);
  \Drupal::setContainer($this->container);

  // Create the directories within the root path within which the Update
  // Manager will install projects.
  foreach (drupal_get_updaters() as $updater_info) {
    $updater = $updater_info['class'];
    $install_directory = $update_root . '/' . $updater::getRootDirectoryRelativePath();
    if (!is_dir($install_directory)) {
      mkdir($install_directory);
    }
  }
}