You are here

function PasswordPolicyTestCase::testLengthConstraint in Password Policy 6

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

File

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

Class

PasswordPolicyTestCase
@file Unit tests for Password policy module.

Code

function testLengthConstraint() {
  module_load_include('inc', 'password_policy', 'constraints/constraint_length');
  $constraint = 6;
  $uid = 0;
  $pass = 'abcde';
  $result = password_policy_constraint_length_validate($pass, $constraint, $uid);
  $this
    ->assertFalse($result, 'Five characters password in the length constraint with param 6');
  $pass = 'abcdef';
  $result = password_policy_constraint_length_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'Six characters password in the length constraint with param 6');
  $pass = 'abcdefg';
  $result = password_policy_constraint_length_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'Seven characters password in the length constraint with param 6');
}