You are here

function PasswordPolicyTestCase::testComplexityConstraint in Password Policy 6

File

tests/password_policy.test, line 130
Unit tests for Password policy module.

Class

PasswordPolicyTestCase
@file Unit tests for Password policy module.

Code

function testComplexityConstraint() {
  module_load_include('inc', 'password_policy', 'constraints/constraint_complexity');
  $constraint = 2;
  $uid = 0;
  $pass = 'abc';
  $result = password_policy_constraint_complexity_validate($pass, $constraint, $uid);
  $this
    ->assertFalse($result, 'Three letters in the type constraint with param 2');
  $pass = 'a1c';
  $result = password_policy_constraint_complexity_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'Two letters and one digit in the type constraint with param 2');
  $pass = 'a1&';
  $result = password_policy_constraint_complexity_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'One letter, one digit and one punctuation in the type constraint with param 2');
}