function LoginSecurityUserBlockingTest::testUserBlocking in Login Security 6
Same name and namespace in other branches
- 7 login_security.test \LoginSecurityUserBlockingTest::testUserBlocking()
File
- ./login_security.test, line 77
- Test the basic functions of the Login Security module.
Class
- LoginSecurityUserBlockingTest
Code
function testUserBlocking() {
$login_attempts_limit = 2;
variable_set('login_security_user_wrong_count', $login_attempts_limit);
variable_set('login_security_user_blocked_email_user', '');
$normal_user = $this
->drupalCreateUser(array(
'access content',
));
$normal_user->pass_raw = user_password();
variable_set('login_security_notice_attempts_available', 1);
$this
->drupalLoginLite($normal_user);
$this
->assertText("You have used 1 out of {$login_attempts_limit} login attempts. After all {$login_attempts_limit} have been used, you will be unable to login.", t('Attempts available message displayed.'));
$this
->assertFieldByName('form_id', 'user_login', t('Login form found.'));
variable_set('login_security_notice_attempts_available', 0);
$this
->drupalLoginLite($normal_user);
$this
->assertNoText("You have used 2 out of {$login_attempts_limit} login attempts. After all {$login_attempts_limit} have been used, you will be unable to login.", t('Attempts available message displayed.'));
$this
->assertFieldByName('form_id', 'user_login', t('Login form found.'));
$this
->assertText("The user {$normal_user->name} has been blocked due to failed login attempts.", t('Blocked message displayed.'));
$this
->assertFieldByName('form_id', 'user_login', t('Login form found.'));
}