You are here

public function PasswordPolicyTestCase::testPunctuationConstraint in Password Policy 7

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

Test punctuation constraint.

File

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

Class

PasswordPolicyTestCase
Tests of basic Password Policy constraints.

Code

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