function UiHelperTrait::drupalResetSession

Same name in other branches
  1. 10 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalResetSession()

Resets the current active session back to Anonymous session.

3 calls to UiHelperTrait::drupalResetSession()
JsonApiFunctionalTest::testRead in core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalTest.php
Tests the GET method.
UiHelperTrait::drupalLogout in core/tests/Drupal/Tests/UiHelperTrait.php
Logs a user out of the Mink controlled browser and confirms.
UserLogoutTest::testLogout in core/modules/user/tests/src/Functional/UserLogoutTest.php
Tests user logout functionality.

File

core/tests/Drupal/Tests/UiHelperTrait.php, line 212

Class

UiHelperTrait
Provides UI helper methods.

Namespace

Drupal\Tests

Code

protected function drupalResetSession() : void {
    // @see BrowserTestBase::drupalUserIsLoggedIn()
    unset($this->loggedInUser->sessionId);
    $this->loggedInUser = FALSE;
    \Drupal::currentUser()->setAccount(new AnonymousUserSession());
}

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