You are here

function SessionTest::sessionReset in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/src/Tests/Session/SessionTest.php \Drupal\system\Tests\Session\SessionTest::sessionReset()

Reset the cookie file so that it refers to the specified user.

Parameters

$uid User id to set as the active session.:

2 calls to SessionTest::sessionReset()
SessionTest::testDataPersistence in core/modules/system/src/Tests/Session/SessionTest.php
Test data persistence via the session_test module callbacks.
SessionTest::testSessionSaveRegenerate in core/modules/system/src/Tests/Session/SessionTest.php
Tests for \Drupal\Core\Session\WriteSafeSessionHandler::setSessionWritable() ::isSessionWritable and \Drupal\Core\Session\SessionManager::regenerate().

File

core/modules/system/src/Tests/Session/SessionTest.php, line 292
Contains \Drupal\system\Tests\Session\SessionTest.

Class

SessionTest
Drupal session handling tests.

Namespace

Drupal\system\Tests\Session

Code

function sessionReset($uid = 0) {

  // Close the internal browser.
  $this
    ->curlClose();
  $this->loggedInUser = FALSE;

  // Change cookie file for user.
  $this->cookieFile = \Drupal::service('stream_wrapper_manager')
    ->getViaScheme('temporary')
    ->getDirectoryPath() . '/cookie.' . $uid . '.txt';
  $this->additionalCurlOptions[CURLOPT_COOKIEFILE] = $this->cookieFile;
  $this->additionalCurlOptions[CURLOPT_COOKIESESSION] = TRUE;
  $this
    ->drupalGet('session-test/get');
  $this
    ->assertResponse(200, 'Session test module is correctly enabled.', 'Session');
}