You are here

function PasswordPolicyTestCase::testAlphanumericConstraint in Password Policy 6

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

File

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

Class

PasswordPolicyTestCase
@file Unit tests for Password policy module.

Code

function testAlphanumericConstraint() {
  module_load_include('inc', 'password_policy', 'constraints/constraint_alphanumeric');
  $constraint = 2;
  $uid = 0;
  $pass = '1$%';
  $result = password_policy_constraint_alphanumeric_validate($pass, $constraint, $uid);
  $this
    ->assertFalse($result, 'One digit and no letter in the alphanumeric constraint with param 2');
  $pass = '1a#';
  $result = password_policy_constraint_alphanumeric_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'One digit and one letter in the alphanumeric constraint with param 2');
  $pass = '1ab';
  $result = password_policy_constraint_alphanumeric_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'One digit ant two letters in the alphanumeric constraint with param 2');
}