protected function SessionLimitBaseTestCase::drupalLoginExpectFail in Session Limit 7.2
Same name and namespace in other branches
- 8 tests/session_limit.test \SessionLimitBaseTestCase::drupalLoginExpectFail()
- 6.2 tests/session_limit.test \SessionLimitBaseTestCase::drupalLoginExpectFail()
- 2.x tests/session_limit.test \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/
session_limit.test - Test that new sessions cannot be created past a maximum.
File
- tests/
session_limit.test, line 276 - Simpletest tests for session_limit.
Class
- SessionLimitBaseTestCase
- Base test for session limits.
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;
}
}