protected function PasswordPolicyAdministratorPasswordChangeTestCase::attemptNonAdminPasswordChanges in Password Policy 7
Attempts to change password for non-administrator.
This is intended to check that the password policy of the non-administrator is applied and not the password policy of the administrator.
1 call to PasswordPolicyAdministratorPasswordChangeTestCase::attemptNonAdminPasswordChanges()
- PasswordPolicyAdministratorPasswordChangeTestCase::testAdministratorPasswordChange in tests/
password_policy.test - Tests administrator changing password of another user.
File
- tests/
password_policy.test, line 876 - Functional tests for Password policy module.
Class
- PasswordPolicyAdministratorPasswordChangeTestCase
- Tests administrator changing password of another user.
Code
protected function attemptNonAdminPasswordChanges() {
$nonadmin_uid = $this->nonadmin->uid;
$nonadmin_user_edit_path = 'user/' . $nonadmin_uid . '/edit';
$policy_rid = $this->policyRid;
$pass = 'foo';
$edit = array(
'pass[pass1]' => $pass,
'pass[pass2]' => $pass,
);
$this
->drupalPost($nonadmin_user_edit_path, $edit, t('Save'));
$this
->assertText(t('The changes have been saved.'), 'Change password without policy applied.');
$pass = 'foo';
$edit = array(
"roles[{$policy_rid}]" => $policy_rid,
'pass[pass1]' => $pass,
'pass[pass2]' => $pass,
);
$this
->drupalPost($nonadmin_user_edit_path, $edit, t('Save'));
$this
->assertText(t('Password must be at least 4 characters in length.'), 'Password not accepted that is invalid per policy that applies to administrator-selected role.');
$pass = 'foobar';
$edit = array(
"roles[{$policy_rid}]" => $policy_rid,
'pass[pass1]' => $pass,
'pass[pass2]' => $pass,
);
$this
->drupalPost($nonadmin_user_edit_path, $edit, t('Save'));
$this
->assertText(t('The changes have been saved.'), 'Password accepted that is valid per policy that applies to administrator-selected role.');
$pass = 'foo';
$edit = array(
'pass[pass1]' => $pass,
'pass[pass2]' => $pass,
);
$this
->drupalPost($nonadmin_user_edit_path, $edit, t('Save'));
$this
->assertText(t('Password must be at least 4 characters in length.'), 'Password not accepted that is invalid per policy that applies to role of user.');
$pass = 'foobar';
$edit = array(
'pass[pass1]' => $pass,
'pass[pass2]' => $pass,
);
$this
->drupalPost($nonadmin_user_edit_path, $edit, t('Save'));
$this
->assertText(t('The changes have been saved.'), 'Password accepted that is valid per policy that applies to role of user.');
}