You are here

public function PasswordPolicyForcePasswordChangeTestCase::testSelfChange in Password Policy 6

Same name and namespace in other branches
  1. 7 tests/password_policy.test \PasswordPolicyForcePasswordChangeTestCase::testSelfChange()

File

tests/password_policy.test, line 412
Unit tests for Password policy module.

Class

PasswordPolicyForcePasswordChangeTestCase

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.'), t('Admin should not be prompted to change password yet.'));
  $edit = array(
    'force_password_change' => TRUE,
  );
  $this
    ->drupalPost("user/{$admin->uid}/edit", $edit, t('Save'));
  $this
    ->assertRaw(t('The changes have been saved.'), t('Admin has queued account for password change.'));
  $this
    ->assertNoRaw(t('Your password has expired. You must change your password to proceed on the site.'), t('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.'), t('Admin forced to change password once they try to leave account page.'));
  $edit = array(
    'mail' => $admin->mail,
    'pass[pass1]' => 'fpcR@nd0m!',
    'pass[pass2]' => 'fpcR@nd0m!',
  );
  $this
    ->drupalPost("user/{$admin->uid}/edit", $edit, t('Save'));
  $this
    ->assertRaw(t('The changes have been saved.'), t('Admin changed password.'));
  $this
    ->drupalGet('node');
  $this
    ->assertNoRaw(t('Your password has expired. You must change your password to proceed on the site.'), t('Not prompted to change password a 2nd time.'));
}