You are here

public function AutologoutSessionCleanupOnLoginTest::stashSession in Automated Logout 8

Initialises a new unique session.

Return value

string Unique identifier for the session just stored.

2 calls to AutologoutSessionCleanupOnLoginTest::stashSession()
AutologoutSessionCleanupOnLoginTest::restoreSession in tests/src/Functional/AutologoutSessionCleanupOnLoginTest.php
Restores a previously stashed session.
AutologoutSessionCleanupOnLoginTest::testSessionCleanupAtLogin in tests/src/Functional/AutologoutSessionCleanupOnLoginTest.php
Tests that stale sessions are cleaned up at login.

File

tests/src/Functional/AutologoutSessionCleanupOnLoginTest.php, line 169

Class

AutologoutSessionCleanupOnLoginTest
Tests session cleanup on login.

Namespace

Drupal\Tests\autologout\Functional

Code

public function stashSession() {
  if (empty($this
    ->getSessionName())) {
    return 0;
  }
  $session_id = $this->privilegedUser->sessionId;
  do {
    $this
      ->generateSessionName($this
      ->randomMachineName());
  } while (isset($this->loggedInUsers[$this
    ->getSessionName()]));
  $this->loggedInUsers[$session_id] = clone $this->privilegedUser;
  $this->mink
    ->registerSession($this
    ->getSessionName(), new Session(new GoutteDriver()));
  $this->mink
    ->setDefaultSessionName($this
    ->getSessionName());
  $this->loggedInUser = FALSE;
  return $session_id;
}