public function PasswordPolicyForcePasswordChangeTestCase::testSelfChange in Password Policy 7
Same name and namespace in other branches
- 6 tests/password_policy.test \PasswordPolicyForcePasswordChangeTestCase::testSelfChange()
Tests admin forcing their own account to reset.
File
- tests/
password_policy.test, line 525 - Functional tests for Password policy module.
Class
- PasswordPolicyForcePasswordChangeTestCase
- Tests of forcing password changes.
Code
public function testSelfChange() {
$admin = $this
->drupalCreateUser(array(
'administer users',
'force password change',
));
$this
->drupalLogin($admin);
$this
->assertNoRaw(t('Your password has expired. You must change your password to proceed on the site.'), 'Admin should not be prompted to change password yet.');
$edit = array(
'force_password_change' => TRUE,
);
$this
->drupalPost("user/{$admin->uid}/edit/account", $edit, t('Save'));
$this
->assertRaw(t('The changes have been saved.'), 'Admin has queued account for password change.');
$this
->assertNoRaw(t('Your password has expired. You must change your password to proceed on the site.'), 'Admin not initially prompted to change password.');
$this
->drupalGet('node');
$this
->assertRaw(t('Your password has expired. You must change your password to proceed on the site.'), 'Admin forced to change password once they try to leave account page.');
$edit = array(
'current_pass' => $admin->pass_raw,
'pass[pass1]' => 'fpcR@nd0m!',
'pass[pass2]' => 'fpcR@nd0m!',
);
$this
->drupalPost("user/{$admin->uid}/edit/account", $edit, t('Save'));
$this
->assertRaw(t('The changes have been saved.'), 'Admin changed password.');
$this
->drupalGet('node');
$this
->assertNoRaw(t('Your password has expired. You must change your password to proceed on the site.'), 'Not prompted to change password a 2nd time.');
}