You are here

protected function PasswordPolicyAdministratorPasswordChangeTestCase::enablePolicy in Password Policy 7

Enables policy.

1 call to PasswordPolicyAdministratorPasswordChangeTestCase::enablePolicy()
PasswordPolicyAdministratorPasswordChangeTestCase::setPolicyThatAppliesToNewRole in tests/password_policy.test
Set a password policy that applies just to the non-administrator.

File

tests/password_policy.test, line 948
Functional tests for Password policy module.

Class

PasswordPolicyAdministratorPasswordChangeTestCase
Tests administrator changing password of another user.

Code

protected function enablePolicy($policy_name) {
  $pid = db_query('SELECT pid FROM {password_policy} WHERE name = :name', array(
    ':name' => $policy_name,
  ))
    ->fetchField();
  $edit = array(
    "policies[{$pid}][enabled]" => $pid,
  );
  $this
    ->drupalPost('admin/config/people/password_policy/list', $edit, t('Save changes'));
  $this
    ->assertText(t('The changes have been saved.'), 'Form submitted successfully.');
  $this
    ->drupalGet('admin/config/people/password_policy');
  $enabled = db_query('SELECT enabled FROM {password_policy} WHERE pid = :pid', array(
    ':pid' => $pid,
  ))
    ->fetchField();
  $this
    ->assertTrue($enabled == 1, 'Policy enabled.');
}