You are here

public function PasswordPolicyTestCase::testDigitConstraint in Password Policy 7

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

Test digit constraint.

File

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

Class

PasswordPolicyTestCase
Tests of basic Password Policy constraints.

Code

public function testDigitConstraint() {
  module_load_include('inc', 'password_policy', 'constraints/constraint_digit');
  $constraint = 2;
  $user = $this
    ->drupalCreateUser();
  $pass = '1ab';
  $result = password_policy_constraint_digit_validate($pass, $constraint, $user);
  $this
    ->assertFalse($result, 'One digit in the digit constraint with param 2');
  $pass = '12a';
  $result = password_policy_constraint_digit_validate($pass, $constraint, $user);
  $this
    ->assertTrue($result, 'Two digits in the digit constraint with param 2');
  $pass = '123';
  $result = password_policy_constraint_digit_validate($pass, $constraint, $user);
  $this
    ->assertTrue($result, 'Three digits in the digit constraint with param 2');
}