You are here

protected function PasswordPolicyPasswordLengthRestrictionTestCase::enablePolicy in Password Policy 7

Enables policy.

1 call to PasswordPolicyPasswordLengthRestrictionTestCase::enablePolicy()
PasswordPolicyPasswordLengthRestrictionTestCase::setPolicyThatAppliesToAuthenticatedUser in tests/password_policy.test
Sets a password policy that applies to the authenticated user role.

File

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

Class

PasswordPolicyPasswordLengthRestrictionTestCase
Tests of restriction on password length.

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.');
}