@@ -25,6 +25,14 @@ public function testCountryCodeWithCorrectSizeButInvalid()
25
25
]));
26
26
}
27
27
28
+ public function testCountryCodeArrayIsInvalid ()
29
+ {
30
+ $ this ->assertFalse ($ this ->performValidation ([
31
+ 'data ' => ['country ' => ['US ' ]],
32
+ 'rules ' => ['country ' => 'country_code ' ],
33
+ ]));
34
+ }
35
+
28
36
public function testCorrectCountryCode ()
29
37
{
30
38
$ this ->assertTrue ($ this ->performValidation ([
@@ -45,11 +53,51 @@ public function testWrongCountryName()
45
53
]));
46
54
}
47
55
56
+ public function testCountryNameArrayIsInvalid ()
57
+ {
58
+ $ this ->assertFalse ($ this ->performValidation ([
59
+ 'data ' => ['country ' => ['United States ' ]],
60
+ 'rules ' => ['country ' => 'country_name ' ],
61
+ ]));
62
+ }
63
+
48
64
public function testCorrectCountryName ()
49
65
{
50
66
$ this ->assertTrue ($ this ->performValidation ([
51
67
'data ' => ['country ' => 'United States ' ],
52
68
'rules ' => ['country ' => 'country_name ' ],
53
69
]));
54
70
}
71
+
72
+ public function testGeneralCountryValidation ()
73
+ {
74
+ // Valid country code
75
+ $ this ->assertTrue ($ this ->performValidation ([
76
+ 'data ' => ['country ' => 'US ' ],
77
+ 'rules ' => ['country ' => 'country ' ],
78
+ ]));
79
+ // Invalid country code
80
+ $ this ->assertFalse ($ this ->performValidation ([
81
+ 'data ' => ['country ' => 'ZZ ' ],
82
+ 'rules ' => ['country ' => 'country ' ],
83
+ ]));
84
+ // Valid country using its name
85
+ $ this ->assertTrue ($ this ->performValidation ([
86
+ 'data ' => ['country ' => 'United States ' ],
87
+ 'rules ' => ['country ' => 'country ' ],
88
+ ]));
89
+ // Invalid country using its name
90
+ $ this ->assertFalse ($ this ->performValidation ([
91
+ 'data ' => ['country ' => 'United Stattes ' ],
92
+ 'rules ' => ['country ' => 'country ' ],
93
+ ]));
94
+ }
95
+
96
+ public function testGeneralCountryArrayIsInvalid ()
97
+ {
98
+ $ this ->assertFalse ($ this ->performValidation ([
99
+ 'data ' => ['country ' => ['United States ' ]],
100
+ 'rules ' => ['country ' => 'country ' ],
101
+ ]));
102
+ }
55
103
}
0 commit comments