function UiHelperTrait::drupalLogout

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalLogout()
  2. 11.x 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.

84 calls to UiHelperTrait::drupalLogout()
AccessDeniedTest::testAccessDenied in core/modules/system/tests/src/Functional/System/AccessDeniedTest.php
BreadcrumbTest::testBreadCrumbs in core/modules/system/tests/src/Functional/Menu/BreadcrumbTest.php
Tests breadcrumbs on node and administrative paths.
CommentAttributesTest::testCommentRdfaMarkup in core/modules/rdf/tests/src/Functional/CommentAttributesTest.php
Tests if RDFa markup for meta information is present in comments.
ConfigExportUITest::testExport in core/modules/config/tests/src/Functional/ConfigExportUITest.php
Tests export of configuration.
ConfigLanguageOverrideWebTest::testSiteNameTranslation in core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php
Tests translating the site name.

... See full list

File

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

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());
}

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