ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PasswordContraintsTest Class Reference

Test standard-constraints of a password. More...

+ Inheritance diagram for PasswordContraintsTest:
+ Collaboration diagram for PasswordContraintsTest:

Public Member Functions

 constraintsProvider ()
 Test a set of values. More...
 
 testAccept ($constraint, $ok_values, $error_values)
 constraintsProvider More...
 

Detailed Description

Test standard-constraints of a password.

Author
Nils Haagen nils..nosp@m.haag.nosp@m.en@co.nosp@m.ncep.nosp@m.ts-an.nosp@m.d-tr.nosp@m.ainin.nosp@m.g.de

Definition at line 15 of file PasswordContraintsTest.php.

Member Function Documentation

◆ constraintsProvider()

PasswordContraintsTest::constraintsProvider ( )

Test a set of values.

Returns
array[[$constraint,$ok_values,$error_values]]

Definition at line 23 of file PasswordContraintsTest.php.

References $d, and $lng.

24  {
25  $lng = $this->createMock(\ilLanguage::class);
26  $d = new \ILIAS\Data\Factory();
27  $validation = new \ILIAS\Validation\Factory($d, $lng);
28  $v = $validation->password();
29 
30  return array(
31  array(
32  $v->hasMinLength(3),
33  [$d->password('abc'), $d->password('abcd')],
34  [$d->password('a'), $d->password('ab')]
35  ),
36  array(
37  $v->hasLowerChars(),
38  [$d->password('abc'), $d->password('AbC')],
39  [$d->password('AB'), $d->password('21'), $d->password('#*+')]
40  ),
41 
42  array(
43  $v->hasUpperChars(),
44  [$d->password('Abc'), $d->password('ABC')],
45  [$d->password('abc'), $d->password('21'), $d->password('#*+')]
46  ),
47  array(
48  $v->hasNumbers(),
49  [$d->password('Ab1'), $d->password('123')],
50  [$d->password('abc'), $d->password('ABC'), $d->password('#*+')]
51  ),
52 
53  array(
54  $v->hasSpecialChars(),
55  [$d->password('Ab+'), $d->password('123#')],
56  [$d->password('abc'), $d->password('ABC'), $d->password('123')]
57  )
58  );
59  }
$lng
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296

◆ testAccept()

PasswordContraintsTest::testAccept (   $constraint,
  $ok_values,
  $error_values 
)

constraintsProvider

Definition at line 64 of file PasswordContraintsTest.php.

65  {
66  foreach ($ok_values as $ok_value) {
67  $this->assertTrue($constraint->accepts($ok_value));
68  }
69  foreach ($error_values as $error_value) {
70  $this->assertFalse($constraint->accepts($error_value));
71  }
72  }

The documentation for this class was generated from the following file: