function UpdatePathTestBase::setUp

Same name in this branch
  1. 8.9.x core/modules/system/src/Tests/Update/UpdatePathTestBase.php \Drupal\system\Tests\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 BrowserTestBase::setUp

12 calls to UpdatePathTestBase::setUp()
ContentTranslationUpdateTest::setUp in core/modules/content_translation/tests/src/Functional/Update/ContentTranslationUpdateTest.php
Overrides WebTestBase::setUp() for update testing.
EntityUpdateAddRevisionDefaultTest::setUp in core/modules/system/tests/src/Functional/Update/EntityUpdateAddRevisionDefaultTest.php
Overrides WebTestBase::setUp() for update testing.
EntityUpdateAddRevisionTranslationAffectedTest::setUp in core/modules/system/tests/src/Functional/Update/EntityUpdateAddRevisionTranslationAffectedTest.php
Overrides WebTestBase::setUp() for update testing.
EntityUpdateToPublishableTest::setUp in core/modules/system/tests/src/Functional/Update/EntityUpdateToPublishableTest.php
Overrides WebTestBase::setUp() for update testing.
FieldUpdateTest::setUp in core/modules/field/tests/src/Functional/Update/FieldUpdateTest.php
Overrides WebTestBase::setUp() for update testing.

... See full list

12 methods override UpdatePathTestBase::setUp()
ContentTranslationUpdateTest::setUp in core/modules/content_translation/tests/src/Functional/Update/ContentTranslationUpdateTest.php
Overrides WebTestBase::setUp() for update testing.
EntityUpdateAddRevisionDefaultTest::setUp in core/modules/system/tests/src/Functional/Update/EntityUpdateAddRevisionDefaultTest.php
Overrides WebTestBase::setUp() for update testing.
EntityUpdateAddRevisionTranslationAffectedTest::setUp in core/modules/system/tests/src/Functional/Update/EntityUpdateAddRevisionTranslationAffectedTest.php
Overrides WebTestBase::setUp() for update testing.
EntityUpdateToPublishableTest::setUp in core/modules/system/tests/src/Functional/Update/EntityUpdateToPublishableTest.php
Overrides WebTestBase::setUp() for update testing.
FieldUpdateTest::setUp in core/modules/field/tests/src/Functional/Update/FieldUpdateTest.php
Overrides WebTestBase::setUp() for update testing.

... See full list

File

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

Class

UpdatePathTestBase
Provides a base class for writing an update test.

Namespace

Drupal\FunctionalTests\Update

Code

protected function setUp() {
    $request = Request::createFromGlobals();
    // Boot up Drupal into a state where calling the database API is possible.
    // This is used to initialize the database system, so we can load the dump
    // files.
    $autoloader = (require $this->root . '/autoload.php');
    $kernel = TestRunnerKernel::createFromRequest($request, $autoloader);
    $kernel->loadLegacyIncludes();
    // 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->setupBaseUrl();
    // Install Drupal test site.
    $this->prepareEnvironment();
    $this->runDbTasks();
    // 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;
    }
    $this->installDrupal();
    // 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';
    // Setup Mink.
    $this->initMink();
    // Set up the browser test output file.
    $this->initBrowserOutputFile();
}

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