File tree Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Expand file tree Collapse file tree 1 file changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Arifszn \AdvancedValidation \Tests \Rules ;
4+
5+ use Arifszn \AdvancedValidation \Rules \Username ;
6+ use Arifszn \AdvancedValidation \Tests \TestCase ;
7+
8+ class UsernameTest extends TestCase
9+ {
10+ /**
11+ * @dataProvider provider
12+ */
13+ public function testValidation ($ result , $ value )
14+ {
15+ $ this ->assertEquals ($ result , (new Username ())->passes ('foo ' , $ value ));
16+ }
17+
18+ public function provider ()
19+ {
20+ return [
21+ [true , 'john ' ],
22+ [true , 'john.doe ' ],
23+ [true , 'john_doe ' ],
24+ [true , 'john-doe ' ],
25+ [true , 'john.doe.123 ' ],
26+ [true , 'john123 ' ],
27+ [true , 'john_123 ' ],
28+ [true , 'john-123 ' ],
29+
30+ [false , '_john ' ],
31+ [false , '-john ' ],
32+ [false , '.john ' ],
33+ [false , 'john_ ' ],
34+ [false , 'john- ' ],
35+ [false , 'john. ' ],
36+ [false , '_john_ ' ],
37+ [false , 'john__doe ' ],
38+ [false , 'john--doe ' ],
39+ [false , 'john..doe ' ],
40+ [false , '123 ' ],
41+ [false , '123.john ' ],
42+ [false , ' ' ],
43+ [false , 'a b c ' ],
44+ [false , 'foobar ' ],
45+ [false , '😀 ' ],
46+ ];
47+ }
48+ }
You can’t perform that action at this time.
0 commit comments