function WebTestBase::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 TestBase::setUp

29 calls to WebTestBase::setUp()
AggregatorTestBase::setUp in core/modules/aggregator/src/Tests/AggregatorTestBase.php
Sets up a Drupal site for running functional and integration tests.
BlockContentTestBase::setUp in core/modules/block_content/src/Tests/BlockContentTestBase.php
Sets the test up.
BlockTestBase::setUp in core/modules/block/src/Tests/BlockTestBase.php
Sets up a Drupal site for running functional and integration tests.
BrokenSetUpTest::setUp in core/modules/simpletest/src/Tests/BrokenSetUpTest.php
Sets up a Drupal site for running functional and integration tests.
BrowserTest::setUp in core/modules/simpletest/src/Tests/BrowserTest.php
Sets up a Drupal site for running functional and integration tests.

... See full list

30 methods override WebTestBase::setUp()
AggregatorTestBase::setUp in core/modules/aggregator/src/Tests/AggregatorTestBase.php
Sets up a Drupal site for running functional and integration tests.
BlockContentTestBase::setUp in core/modules/block_content/src/Tests/BlockContentTestBase.php
Sets the test up.
BlockTestBase::setUp in core/modules/block/src/Tests/BlockTestBase.php
Sets up a Drupal site for running functional and integration tests.
BrokenSetUpTest::setUp in core/modules/simpletest/src/Tests/BrokenSetUpTest.php
Sets up a Drupal site for running functional and integration tests.
BrowserTest::setUp in core/modules/simpletest/src/Tests/BrowserTest.php
Sets up a Drupal site for running functional and integration tests.

... See full list

File

core/modules/simpletest/src/WebTestBase.php, line 365

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function setUp() {
    // Set an explicit time zone to not rely on the system one, which may vary
    // from setup to setup. The Australia/Sydney time zone is chosen so all
    // tests are run using an edge case scenario (UTC+10 and DST). This choice
    // is made to prevent time zone related regressions and reduce the
    // fragility of the testing system in general. This is also set in config in
    // \Drupal\simpletest\WebTestBase::initConfig().
    date_default_timezone_set('Australia/Sydney');
    // Preserve original batch for later restoration.
    $this->setBatch();
    // Initialize user 1 and session name.
    $this->initUserSession();
    // Prepare the child site settings.
    $this->prepareSettings();
    // Execute the non-interactive installer.
    $this->doInstall();
    // Import new settings.php written by the installer.
    $this->initSettings();
    // Initialize the request and container post-install.
    $container = $this->initKernel(\Drupal::request());
    // Initialize and override certain configurations.
    $this->initConfig($container);
    $this->installDefaultThemeFromClassProperty($container);
    // Collect modules to install.
    $this->installModulesFromClassProperty($container);
    // Restore the original batch.
    $this->restoreBatch();
    // Reset/rebuild everything.
    $this->rebuildAll();
}

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