@@ -13,9 +13,9 @@ public function testItCreatesAnInstanceOfPhoneValidator()
13
13
$ this ->assertInstanceOf (PhoneValidator::class, $ obj );
14
14
}
15
15
16
- protected function validate ($ color , $ rule = 'phone ' )
16
+ protected function validate ($ number , $ rule = 'phone ' )
17
17
{
18
- return !(Validator::make (['test ' => $ color ], ['test ' => $ rule ])->fails ());
18
+ return !(Validator::make (['attr ' => $ number ], ['attr ' => $ rule ])->fails ());
19
19
}
20
20
21
21
public function testValidatorPhone ()
@@ -25,11 +25,17 @@ public function testValidatorPhone()
25
25
26
26
public function testValidatorPhoneE164 ()
27
27
{
28
- $ this ->assertEquals (true , $ this ->validate ('+15556667777 ' , 'phone:E164 ' ));
28
+ $ this ->assertEquals (true , $ this ->validate ('+15556660000 ' , 'phone:E164 ' ));
29
29
$ this ->assertEquals (false , $ this ->validate ('+1555 ex 1234 ' , 'phone:E164 ' ));
30
30
$ this ->assertEquals (false , $ this ->validate ('+155566677775556667777 ' , 'phone:E164 ' ));
31
31
$ this ->assertEquals (false , $ this ->validate ('+1555 ' , 'phone:E164 ' ));
32
32
$ this ->assertEquals (false , $ this ->validate ('5556667777 ' , 'phone:E164 ' ));
33
33
$ this ->assertEquals (false , $ this ->validate ('+1(555)666-7777 ' , 'phone:E164 ' ));
34
34
}
35
+
36
+ public function testValidatorErrorMessage ()
37
+ {
38
+ $ validator = Validator::make (['attr ' => '+1555 ex 1234 ' ], ['attr ' => 'phone:E164 ' ]);
39
+ $ this ->assertEquals ("Not a valid phone number " , $ validator ->errors ()->first ());
40
+ }
35
41
}
0 commit comments