You are here

public function PasswordPolicyTestCase::testLengthConstraint in Password Policy 7

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

Test length constraint.

File

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

Class

PasswordPolicyTestCase
Tests of basic Password Policy constraints.

Code

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