function UiHelperTrait::drupalLogout
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalLogout()
- 10 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::drupalLogout()
- 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.
162 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.
- AggregatorRenderingTest::testFeedPage in core/
modules/ aggregator/ tests/ src/ Functional/ AggregatorRenderingTest.php - Creates a feed and checks that feed's page.
- BigPipeTest::testNoJsDetection in core/
modules/ big_pipe/ tests/ src/ Functional/ BigPipeTest.php - Tests BigPipe's no-JS detection.
- BlockCacheTest::testCachePermissions in core/
modules/ block/ tests/ src/ Functional/ BlockCacheTest.php - Tests a cacheable block without any additional cache context.
File
-
core/
tests/ Drupal/ Tests/ UiHelperTrait.php, line 272
Class
- UiHelperTrait
- Provides UI helper methods.
Namespace
Drupal\TestsCode
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.