public function PasswordPolicyTestCase::testDigitPlacementConstraint in Password Policy 7
Same name and namespace in other branches
- 6 tests/password_policy.test \PasswordPolicyTestCase::testDigitPlacementConstraint()
Test digit placement constraint.
File
- tests/
password_policy.test, line 319 - Functional tests for Password policy module.
Class
- PasswordPolicyTestCase
- Tests of basic Password Policy constraints.
Code
public function testDigitPlacementConstraint() {
module_load_include('inc', 'password_policy', 'constraints/constraint_digit_placement');
$constraint = 0;
$user = $this
->drupalCreateUser();
$pass = 'ILove2Password';
$result = password_policy_constraint_digit_placement_validate($pass, $constraint, $user);
$this
->assertTrue($result, 'One numeric character in the digit placement constraint with param 0');
$pass = 'ILovePassword2';
$result = password_policy_constraint_digit_placement_validate($pass, $constraint, $user);
$this
->assertTrue($result, 'One numeric character in the digit placement constraint with param 0');
$constraint = 1;
$pass = 'ILove2Password';
$result = password_policy_constraint_digit_placement_validate($pass, $constraint, $user);
$this
->assertTrue($result, 'One numeric character in the digit placement constraint with param 1');
$pass = 'ILovePassword2';
$result = password_policy_constraint_digit_placement_validate($pass, $constraint, $user);
$this
->assertTrue($result, 'One numeric character in the digit placement constraint with param 1');
$constraint = 2;
$pass = 'ILove2Password';
$result = password_policy_constraint_digit_placement_validate($pass, $constraint, $user);
$this
->assertTrue($result, 'One numeric character in the digit placement constraint with param 2');
$pass = 'ILovePassword2';
$result = password_policy_constraint_digit_placement_validate($pass, $constraint, $user);
$this
->assertFalse($result, 'One numeric character in the digit placement constraint with param 2');
$pass = '1LovePassword';
$result = password_policy_constraint_digit_placement_validate($pass, $constraint, $user);
$this
->assertFalse($result, 'One numeric character in the digit placement constraint with param 2');
$pass = '1LovePassword2';
$result = password_policy_constraint_digit_placement_validate($pass, $constraint, $user);
$this
->assertTrue($result, 'One numeric character in the digit placement constraint with param 2');
$pass = 'ILove2Password3';
$result = password_policy_constraint_digit_placement_validate($pass, $constraint, $user);
$this
->assertTrue($result, 'One numeric character in the digit placement constraint with param 2');
}