File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Expand file tree Collapse file tree 1 file changed +59
-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 \Name ;
6+ use Arifszn \AdvancedValidation \Tests \TestCase ;
7+
8+ class NameTest extends TestCase
9+ {
10+ /**
11+ * @dataProvider providerWithoutAllowNumber
12+ */
13+ public function testValidationWithoutAllowNumber ($ result , $ value )
14+ {
15+ $ this ->assertEquals ($ result , (new Name (false ))->passes ('foo ' , $ value ));
16+ }
17+
18+ /**
19+ * @dataProvider providerWithAllowNumber
20+ */
21+ public function testValidationWithAllowNumber ($ result , $ value )
22+ {
23+ $ this ->assertEquals ($ result , (new Name (true ))->passes ('foo ' , $ value ));
24+ }
25+
26+ public function providerWithoutAllowNumber ()
27+ {
28+ return array_merge ($ this ->shared (), [
29+ [false , '1234 abc DEF ' ],
30+ [false , '1234abcDEF ' ],
31+ [false , '消极的123 ' ],
32+ ]);
33+ }
34+
35+ public function providerWithAllowNumber ()
36+ {
37+ return array_merge ($ this ->shared (), [
38+ [true , '1234 abc DEF ' ],
39+ [true , '1234abcDEF ' ],
40+ [true , '消极的123 ' ],
41+ ]);
42+ }
43+
44+ private function shared ()
45+ {
46+ return [
47+ [true , 'foobar ' ],
48+ [true , 'foobar ' ],
49+ [true , 'a ' ],
50+ [true , '消极的 ' ],
51+ [true , '### ' ],
52+ [true , '** ' ],
53+ [false , '😀 ' ],
54+ [false , 'john 😀 ' ],
55+ [false , '' ],
56+ [false , ' ' ],
57+ ];
58+ }
59+ }
You can’t perform that action at this time.
0 commit comments