You are here

protected function WebTestBase::setUp in SimpleTest 8.3

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

6 calls to WebTestBase::setUp()
BrokenSetUpTest::setUp in src/Tests/BrokenSetUpTest.php
Sets up a Drupal site for running functional and integration tests.
BrowserTest::setUp in src/Tests/BrowserTest.php
Sets up a Drupal site for running functional and integration tests.
MissingCheckedRequirementsTest::setUp in src/Tests/MissingCheckedRequirementsTest.php
Sets up a Drupal site for running functional and integration tests.
SimpleTestBrowserTest::setUp in src/Tests/SimpleTestBrowserTest.php
Sets up a Drupal site for running functional and integration tests.
SimpleTestTest::setUp in src/Tests/SimpleTestTest.php
Sets up a Drupal site for running functional and integration tests.

... See full list

7 methods override WebTestBase::setUp()
BrokenSetUpTest::setUp in src/Tests/BrokenSetUpTest.php
Sets up a Drupal site for running functional and integration tests.
BrowserTest::setUp in src/Tests/BrowserTest.php
Sets up a Drupal site for running functional and integration tests.
InstallerTestBase::setUp in src/InstallerTestBase.php
Sets up a Drupal site for running functional and integration tests.
MissingCheckedRequirementsTest::setUp in src/Tests/MissingCheckedRequirementsTest.php
Sets up a Drupal site for running functional and integration tests.
SimpleTestBrowserTest::setUp in src/Tests/SimpleTestBrowserTest.php
Sets up a Drupal site for running functional and integration tests.

... See full list

File

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();
}