protected function WebTestBase::drupalLogout in Drupal 8
Logs a user out of the internal browser and confirms.
Confirms logout by checking the login page.
3 calls to WebTestBase::drupalLogout()
- SimpleTestBrowserTest::testInternalBrowser in core/
modules/ simpletest/ src/ Tests/ SimpleTestBrowserTest.php - Test the internal browsers functionality.
- SimpleTestBrowserTest::testUserAgentValidation in core/
modules/ simpletest/ src/ Tests/ SimpleTestBrowserTest.php - Test validation of the User-Agent header we use to perform test requests.
- WebTestBase::drupalLogin in core/
modules/ simpletest/ src/ WebTestBase.php - Log in a user with the internal browser.
File
- core/
modules/ simpletest/ src/ WebTestBase.php, line 333
Class
- WebTestBase
- Test case for typical Drupal tests.
Namespace
Drupal\simpletestCode
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.
$this
->drupalGet('user/logout', [
'query' => [
'destination' => 'user/login',
],
]);
$this
->assertResponse(200, 'User was logged out.');
$pass = $this
->assertField('name', 'Username field found.', 'Logout');
$pass = $pass && $this
->assertField('pass', 'Password field found.', 'Logout');
if ($pass) {
// @see WebTestBase::drupalUserIsLoggedIn()
unset($this->loggedInUser->session_id);
$this->loggedInUser = FALSE;
$this->container
->get('current_user')
->setAccount(new AnonymousUserSession());
}
}