You are here

function PasswordPolicyTestCase::testUppercaseConstraint in Password Policy 6

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

File

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

Class

PasswordPolicyTestCase
@file Unit tests for Password policy module.

Code

function testUppercaseConstraint() {
  module_load_include('inc', 'password_policy', 'constraints/constraint_uppercase');
  $constraint = 2;
  $uid = 0;
  $pass = 'Abc';
  $result = password_policy_constraint_uppercase_validate($pass, $constraint, $uid);
  $this
    ->assertFalse($result, 'One uppercase letter in the uppercase constraint with param 2');
  $pass = 'ABc';
  $result = password_policy_constraint_uppercase_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'Two uppercase letters in the uppercase constraint with param 2');
  $pass = 'ABC';
  $result = password_policy_constraint_uppercase_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'Three uppercase letters in the uppercase constraint with param 2');
}