You are here

protected function SessionLimitBaseTestCase::drupalLoginExpectFail in Session Limit 2.x

Same name in this branch
  1. 2.x tests/session_limit.test \SessionLimitBaseTestCase::drupalLoginExpectFail()
  2. 2.x tests/SessionLimitBaseTestCase.php \Drupal\session_limit\SessionLimitBaseTestCase::drupalLoginExpectFail()
Same name and namespace in other branches
  1. 8 tests/SessionLimitBaseTestCase.php \Drupal\session_limit\SessionLimitBaseTestCase::drupalLoginExpectFail()

Log in a user with the internal browser but expect this to fail.

This works as drupalLogin but instead of checking if the login succeeded, it instead checks for not being logged in and fails if it has managed to login successfully.

Parameters

$account: User object representing the user to log in.

See also

drupalCreateUser()

1 call to SessionLimitBaseTestCase::drupalLoginExpectFail()
SessionLimitBaseTestCase::assertSessionPrevent in tests/SessionLimitBaseTestCase.php
Test that new sessions cannot be created past a maximum.

File

tests/SessionLimitBaseTestCase.php, line 272

Class

SessionLimitBaseTestCase
Base test for session limits.

Namespace

Drupal\session_limit

Code

protected function drupalLoginExpectFail(stdClass $account) {
  if ($this->loggedInUser) {
    $this
      ->drupalLogout();
  }
  $edit = array(
    'name' => $account->name,
    'pass' => $account->pass_raw,
  );
  $this
    ->drupalPost('user', $edit, t('Log in'));

  // Check that login was unsuccessful by ensuring there is no log out link.
  $pass = $this
    ->assertNoLink(t('Log out'), 0, t('User %name did not log in.', array(
    '%name' => $account->name,
  )), t('User login'));
  if (!$pass) {
    $this->loggedInUser = $account;
  }
}