| @@ 21-32 (lines=12) @@ | ||
| 18 | } |
|
| 19 | ||
| 20 | /** @test */ |
|
| 21 | public function letterPasswordOnly() |
|
| 22 | {
|
|
| 23 | $pw = new Password(); |
|
| 24 | ||
| 25 | $pw->addCriteria(new Dictionaries\Letter(), new Occurrences\Strict(10)); |
|
| 26 | ||
| 27 | $str = $pw->generate(); |
|
| 28 | ||
| 29 | $this->assertNotEmpty($str); |
|
| 30 | ||
| 31 | $this->assertRegExp('/[a-z]/', $str);
|
|
| 32 | } |
|
| 33 | ||
| 34 | /** @test */ |
|
| 35 | public function alphanumericPasswordOnly() |
|
| @@ 89-102 (lines=14) @@ | ||
| 86 | } |
|
| 87 | ||
| 88 | /** @test */ |
|
| 89 | public function specialCharacterOnly() |
|
| 90 | {
|
|
| 91 | $pw = new Password(); |
|
| 92 | ||
| 93 | $pw->addCriteria(new Dictionaries\SpecialCharacter(), new Occurrences\Strict(5)); |
|
| 94 | ||
| 95 | $str = $pw->generate(); |
|
| 96 | ||
| 97 | $this->assertNotEmpty($str); |
|
| 98 | ||
| 99 | $this->assertEquals(5, mb_strlen($str)); |
|
| 100 | ||
| 101 | $this->assertRegExp('/[\[\&\+\#\|\^\°\=\!\@\%\*\?\_\~\-\§\:\;\.\]]{5}/', $str);
|
|
| 102 | } |
|
| 103 | ||
| 104 | /** @test */ |
|
| 105 | public function longDigitFormatOnly() |
|
| @@ 184-195 (lines=12) @@ | ||
| 181 | ||
| 182 | ||
| 183 | /** @test */ |
|
| 184 | public function digitPasswordOnly() |
|
| 185 | {
|
|
| 186 | $pw = new Password(); |
|
| 187 | ||
| 188 | $pw->addCriteria(new Dictionaries\Digit(), new Occurrences\Strict(10)); |
|
| 189 | ||
| 190 | $str = $pw->generate(); |
|
| 191 | ||
| 192 | $this->assertNotEmpty($str); |
|
| 193 | ||
| 194 | $this->assertRegExp('/\d{10}/', $str);
|
|
| 195 | } |
|
| 196 | ||
| 197 | /** @test */ |
|
| 198 | public function strictOccurrences() |
|