You are here

protected function ConflictWebTestCase::drupalLogout in Conflict 7

Overrides DrupalWebTestCase::drupalLogout().

Parameters

stdClass $account: (optional) The user account to log out.

Overrides DrupalWebTestCase::drupalLogout

2 calls to ConflictWebTestCase::drupalLogout()
ConflictSwitchExampleTestCase::testConcurrentLogin in ./conflict.test
Test internal concurrent session functional.
ConflictWebTestCase::drupalLogin in ./conflict.test
Overrides DrupalWebTestCase::drupalLogin().

File

./conflict.test, line 117
Tests for conflict.module.

Class

ConflictWebTestCase
@file Tests for conflict.module.

Code

protected function drupalLogout(stdClass $account = NULL) {

  // If a specific account was passed, ensure that we are operating on that
  // user's session first.
  if (isset($account) && (!$this->loggedInUser || $account->uid != $this->loggedInUser)) {
    $this
      ->drupalSwitchUser($account);
  }

  // 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');
  $this
    ->drupalGet('user');
  $pass = $this
    ->assertField('name', t('Username field found.'), t('Logout'));
  $pass = $pass && $this
    ->assertField('pass', t('Password field found.'), t('Logout'));
  if ($pass) {

    // Remove the user's session on the account itself.
    if (isset($account->session->curlHandle)) {
      curl_close($account->session->curlHandle);
    }
    unset($account->session);

    // Switch to no session.
    $this->loggedInUser = FALSE;
  }
}