You are here

protected function SecurepagesTest::drupalLogoutHttps in Secure Pages 8

Logs a user out of the internal browser and confirms.

Confirms logout by checking the login page.

1 call to SecurepagesTest::drupalLogoutHttps()
SecurepagesTest::_testSettingsForm in src/Tests/SecurepagesTest.php
Test submitting the settings form.

File

src/Tests/SecurepagesTest.php, line 391
Contains \Drupal\securepages\Tests\SecurepagesTest.

Class

SecurepagesTest
Test Secure Pages redirects.

Namespace

Drupal\securepages\Tests

Code

protected function drupalLogoutHttps() {

  // 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(Securepages::getUrl('user.logout', array(
    'query' => array(
      '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());
  }
}