You are here

trait SessionTestTrait in Drupal 8

Same name in this branch
  1. 8 core/tests/Drupal/Tests/SessionTestTrait.php \Drupal\Tests\SessionTestTrait
  2. 8 core/modules/simpletest/src/SessionTestTrait.php \Drupal\simpletest\SessionTestTrait
Same name and namespace in other branches
  1. 9 core/tests/Drupal/Tests/SessionTestTrait.php \Drupal\Tests\SessionTestTrait

Provides methods to generate and get session name in tests.

Hierarchy

2 files declare their use of SessionTestTrait
FunctionalTestSetupTrait.php in core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php
SessionTestTrait.php in core/modules/simpletest/src/SessionTestTrait.php

File

core/tests/Drupal/Tests/SessionTestTrait.php, line 10

Namespace

Drupal\Tests
View source
trait SessionTestTrait {

  /**
   * The name of the session cookie.
   *
   * @var string
   */
  protected $sessionName;

  /**
   * Generates a session cookie name.
   *
   * @param string $data
   *   The data to generate session name.
   */
  protected function generateSessionName($data) {
    $prefix = Request::createFromGlobals()
      ->isSecure() ? 'SSESS' : 'SESS';
    $this->sessionName = $prefix . substr(hash('sha256', $data), 0, 32);
  }

  /**
   * Returns the session name in use on the child site.
   *
   * @return string
   *   The name of the session cookie.
   */
  protected function getSessionName() {
    return $this->sessionName;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SessionTestTrait::$sessionName protected property The name of the session cookie.
SessionTestTrait::generateSessionName protected function Generates a session cookie name.
SessionTestTrait::getSessionName protected function Returns the session name in use on the child site.