You are here

protected function BrowserTestBase::drupalLogout in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/src/BrowserTestBase.php \Drupal\simpletest\BrowserTestBase::drupalLogout()

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

Confirms logout by checking the login page.

1 call to BrowserTestBase::drupalLogout()
BrowserTestBase::drupalLogin in core/modules/simpletest/src/BrowserTestBase.php
Logs in a user using the Mink controlled browser.

File

core/modules/simpletest/src/BrowserTestBase.php, line 712
Contains \Drupal\simpletest\BrowserTestBase.

Class

BrowserTestBase
Provides a test case for functional Drupal tests.

Namespace

Drupal\simpletest

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();
  $this
    ->drupalGet('user/logout', array(
    'query' => array(
      'destination' => 'user',
    ),
  ));
  $assert_session
    ->statusCodeEquals(200);
  $assert_session
    ->fieldExists('name');
  $assert_session
    ->fieldExists('pass');

  // @see BrowserTestBase::drupalUserIsLoggedIn()
  unset($this->loggedInUser->sessionId);
  $this->loggedInUser = FALSE;
  $this->container
    ->get('current_user')
    ->setAccount(new AnonymousUserSession());
}