@@ -13,14 +13,43 @@ public function testArrayWithPresentKeyShouldReturnTrue()
13
13
$ this ->assertTrue ($ validator ->validate ($ obj ));
14
14
}
15
15
16
+ public function testEmptyInputMustReturnTrue ()
17
+ {
18
+ $ validator = new Key ('someEmptyKey ' );
19
+ $ input = '' ;
20
+
21
+ $ this ->assertTrue ($ validator ->assert ($ input ));
22
+ $ this ->assertTrue ($ validator ->check ($ input ));
23
+ $ this ->assertTrue ($ validator ->validate ($ input ));
24
+ }
25
+
16
26
public function testArrayWithEmptyKeyShouldReturnTrue ()
17
27
{
18
28
$ validator = new Key ('someEmptyKey ' );
19
- $ obj = array ();
20
- $ obj ['someEmptyKey ' ] = '' ;
21
- $ this ->assertTrue ($ validator ->assert ($ obj ));
22
- $ this ->assertTrue ($ validator ->check ($ obj ));
23
- $ this ->assertTrue ($ validator ->validate ($ obj ));
29
+ $ input = array ();
30
+ $ input ['someEmptyKey ' ] = '' ;
31
+
32
+ $ this ->assertTrue ($ validator ->assert ($ input ));
33
+ $ this ->assertTrue ($ validator ->check ($ input ));
34
+ $ this ->assertTrue ($ validator ->validate ($ input ));
35
+ }
36
+
37
+ public function testShouldHaveTheSameReturnValueForAllValidators ()
38
+ {
39
+ $ rule = new Key ('key ' , new NotEmpty ());
40
+ $ input = array ('key ' => '' );
41
+
42
+ try {
43
+ $ rule ->assert ($ input );
44
+ $ this ->fail ('`assert()` must throws exception ' );
45
+ } catch (\Exception $ e ) {}
46
+
47
+ try {
48
+ $ rule ->check ($ input );
49
+ $ this ->fail ('`check()` must throws exception ' );
50
+ } catch (\Exception $ e ) {}
51
+
52
+ $ this ->assertFalse ($ rule ->validate ($ input ));
24
53
}
25
54
26
55
/**
0 commit comments