Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FunctionalTestSetupTrait.php

function FunctionalTestSetupTrait::initUserSession

Initializes user 1 for the site to be installed.

File

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

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

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal