function UpdatePathTestBase::setUp

Same name in this branch
  1. 8.9.x core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::setUp()
Same name in other branches
  1. 9 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::setUp()
  2. 10 core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php \Drupal\FunctionalTests\Update\UpdatePathTestBase::setUp()

Overrides WebTestBase::setUp() 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 WebTestBase::setUp

File

core/modules/system/src/Tests/Update/UpdatePathTestBase.php, line 154

Class

UpdatePathTestBase
Provides a base class for writing an update test.

Namespace

Drupal\system\Tests\Update

Code

protected function setUp() {
    $this->runDbTasks();
    // Allow classes to set database dump files.
    $this->setDatabaseDumpFiles();
    // We are going to set a missing zlib requirement property for usage
    // during the performUpgrade() and tearDown() methods. Also set that the
    // tests failed.
    if (!$this->zlibInstalled) {
        parent::setUp();
        return;
    }
    // Set the update url. This must be set here rather than in
    // self::__construct() or the old URL generator will leak additional test
    // sites.
    $this->updateUrl = Url::fromRoute('system.db_update');
    // These methods are called from parent::setUp().
    $this->setBatch();
    $this->initUserSession();
    $this->prepareSettings();
    // Load the database(s).
    foreach ($this->databaseDumpFiles as $file) {
        if (substr($file, -3) == '.gz') {
            $file = "compress.zlib://{$file}";
        }
        require $file;
    }
    $this->initSettings();
    $request = Request::createFromGlobals();
    $container = $this->initKernel($request);
    $this->initConfig($container);
    // Restore the original Simpletest batch.
    $this->restoreBatch();
    // 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 \Drupal::root() . '/core/includes/update.inc';
}

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