You are here

public function PasswordPolicyTestCase::testLetterConstraint in Password Policy 7

Same name and namespace in other branches
  1. 6 tests/password_policy.test \PasswordPolicyTestCase::testLetterConstraint()

Test letter constraint.

File

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

Class

PasswordPolicyTestCase
Tests of basic Password Policy constraints.

Code

public function testLetterConstraint() {
  module_load_include('inc', 'password_policy', 'constraints/constraint_letter');
  $constraint = 2;
  $user = $this
    ->drupalCreateUser();
  $pass = 'a12';
  $result = password_policy_constraint_letter_validate($pass, $constraint, $user);
  $this
    ->assertFalse($result, 'One lowercase letter in the letter constraint with param 2');
  $pass = 'aB1';
  $result = password_policy_constraint_letter_validate($pass, $constraint, $user);
  $this
    ->assertTrue($result, 'One lowercase and one uppercase letter in the letter constraint with param 2');
  $pass = 'abC';
  $result = password_policy_constraint_letter_validate($pass, $constraint, $user);
  $this
    ->assertTrue($result, 'Two lowercase and one uppercase letter in the letter constraint with param 2');
}