function UserLoginTestCase::assertFailedLogin
7.x user.test | UserLoginTestCase::assertFailedLogin($account, $flood_trigger = NULL) |
Make an unsuccessful login attempt.
Parameters
$account: A user object with name and pass_raw attributes for the login attempt.
$flood_trigger: Whether or not to expect that the flood control mechanism will be triggered.
2 calls to UserLoginTestCase::assertFailedLogin()
- UserLoginTestCase::testGlobalLoginFloodControl in drupal-7.x/
modules/ user/ user.test - Test the global login flood control.
- UserLoginTestCase::testPerUserLoginFloodControl in drupal-7.x/
modules/ user/ user.test - Test the per-user login flood control.
File
- drupal-7.x/
modules/ user/ user.test, line 432 - Tests for user.module.
Class
- UserLoginTestCase
- Functional tests for user logins, including rate limiting of login attempts.
Code
function assertFailedLogin($account, $flood_trigger = NULL) {
$edit = array(
'name' => $account->name,
'pass' => $account->pass_raw,
);
$this->drupalPost('user', $edit, t('Log in'));
$this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.');
if (isset($flood_trigger)) {
if ($flood_trigger == 'user') {
$this->assertRaw(format_plural(variable_get('user_failed_login_user_limit', 5), 'Sorry, there has been more than one failed login attempt for this account. It is temporarily blocked. Try again later or <a href="@url">request a new password</a>.', 'Sorry, there have been more than @count failed login attempts for this account. It is temporarily blocked. Try again later or <a href="@url">request a new password</a>.', array('@url' => url('user/password'))));
}
else {
// No uid, so the limit is IP-based.
$this->assertRaw(t('Sorry, too many failed login attempts from your IP address. This IP address is temporarily blocked. Try again later or <a href="@url">request a new password</a>.', array('@url' => url('user/password'))));
}
}
else {
$this->assertText(t('Sorry, unrecognized username or password. Have you forgotten your password?'));
}
}