You are here

protected function UiHelperTrait::drupalLogout in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalLogout()
  2. 9 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalLogout()

Logs a user out of the Mink controlled browser and confirms.

Confirms logout by checking the login page.

21 calls to UiHelperTrait::drupalLogout()
AccessDeniedTest::testAccessDenied in core/modules/system/tests/src/Functional/System/AccessDeniedTest.php
AccessRoleTest::testAccessRole in core/modules/user/tests/src/Functional/Views/AccessRoleTest.php
Tests role access plugin.
BookRelationshipTest::createBook in core/modules/book/tests/src/Functional/Views/BookRelationshipTest.php
Creates a new book with a page hierarchy.
BreadcrumbTest::testBreadCrumbs in core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
Tests breadcrumbs on node and administrative paths.
CommentAdminTest::testApprovalAdminInterface in core/modules/comment/tests/src/Functional/Views/CommentAdminTest.php
Tests comment approval functionality through admin/content/comment.

... See full list

File

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

Class

UiHelperTrait
Provides UI helper methods.

Namespace

Drupal\Tests

Code

protected function drupalLogout() {

  // Make a request to the logout page, and redirect to the user page, the
  // idea being if you were properly logged out you should be seeing a login
  // screen.
  $assert_session = $this
    ->assertSession();
  $destination = Url::fromRoute('user.page')
    ->toString();
  $this
    ->drupalGet(Url::fromRoute('user.logout', [], [
    'query' => [
      'destination' => $destination,
    ],
  ]));
  $assert_session
    ->fieldExists('name');
  $assert_session
    ->fieldExists('pass');

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