ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 16 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 24 of file PasswordContraintsTest.php.

References $d, and $lng.

25  {
26  $lng = $this->createMock(\ilLanguage::class);
27  $d = new \ILIAS\Data\Factory();
28  $refinery = new \ILIAS\Refinery\Factory($d, $lng);
29  $v = $refinery->password();
30 
31  return array(
32  array(
33  $v->hasMinLength(3),
34  [$d->password('abc'), $d->password('abcd')],
35  [$d->password('a'), $d->password('ab')]
36  ),
37  array(
38  $v->hasLowerChars(),
39  [$d->password('abc'), $d->password('AbC')],
40  [$d->password('AB'), $d->password('21'), $d->password('#*+')]
41  ),
42 
43  array(
44  $v->hasUpperChars(),
45  [$d->password('Abc'), $d->password('ABC')],
46  [$d->password('abc'), $d->password('21'), $d->password('#*+')]
47  ),
48  array(
49  $v->hasNumbers(),
50  [$d->password('Ab1'), $d->password('123')],
51  [$d->password('abc'), $d->password('ABC'), $d->password('#*+')]
52  ),
53 
54  array(
55  $v->hasSpecialChars(),
56  [$d->password('Ab+'), $d->password('123#')],
57  [$d->password('abc'), $d->password('ABC'), $d->password('123')]
58  )
59  );
60  }
$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 65 of file PasswordContraintsTest.php.

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

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