function FunctionalTestSetupTrait::initUserSession

Same name in other branches
  1. 9 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::initUserSession()
  2. 10 core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::initUserSession()
  3. 11.x core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php \Drupal\Core\Test\FunctionalTestSetupTrait::initUserSession()

Initializes user 1 for the site to be installed.

5 calls to FunctionalTestSetupTrait::initUserSession()
BrowserTestBase::installDrupal in core/tests/Drupal/Tests/BrowserTestBase.php
Installs Drupal into the Simpletest site.
TestSiteInstallCommand::installDrupal in core/tests/Drupal/TestSite/Commands/TestSiteInstallCommand.php
Installs Drupal into the test site.
UpdatePathTestBase::installDrupal in core/tests/Drupal/FunctionalTests/Update/UpdatePathTestBase.php
Installs Drupal into the Simpletest site.
UpdatePathTestBase::setUp in core/modules/system/src/Tests/Update/UpdatePathTestBase.php
Overrides WebTestBase::setUp() for update testing.
WebTestBase::setUp in core/modules/simpletest/src/WebTestBase.php
Sets up a Drupal site for running functional and integration tests.

File

core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php, line 364

Class

FunctionalTestSetupTrait
Defines a trait for shared functional test setup functionality.

Namespace

Drupal\Core\Test

Code

protected function initUserSession() {
    $password = $this->randomMachineName();
    // Define information about the user 1 account.
    $this->rootUser = new UserSession([
        'uid' => 1,
        'name' => 'admin',
        'mail' => 'admin@example.com',
        'pass_raw' => $password,
        'passRaw' => $password,
        'timezone' => date_default_timezone_get(),
    ]);
    // The child site derives its session name from the database prefix when
    // running web tests.
    $this->generateSessionName($this->databasePrefix);
}

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