You are here

function PasswordPolicyTestCase::testPunctuationConstraint in Password Policy 6

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

File

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

Class

PasswordPolicyTestCase
@file Unit tests for Password policy module.

Code

function testPunctuationConstraint() {
  module_load_include('inc', 'password_policy', 'constraints/constraint_punctuation');
  $constraint = 2;
  $uid = 0;
  $pass = '%1a';
  $result = password_policy_constraint_punctuation_validate($pass, $constraint, $uid);
  $this
    ->assertFalse($result, 'One punctuation character in the punctuation constraint with param 2');
  $pass = '%^a';
  $result = password_policy_constraint_punctuation_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'Two punctuation character in the punctuation constraint with param 2');
  $pass = '%^&';
  $result = password_policy_constraint_punctuation_validate($pass, $constraint, $uid);
  $this
    ->assertTrue($result, 'Three punctuation character in the punctuation constraint with param 2');
}