3
3
namespace lloc \MslsTests ;
4
4
5
5
use Brain \Monkey \Functions ;
6
+ use lloc \Msls \MslsFields ;
6
7
use lloc \Msls \MslsOptions ;
7
8
use lloc \Msls \MslsTaxonomy ;
8
9
@@ -20,11 +21,8 @@ public function get_test( bool $exluded = false ): MslsTaxonomy {
20
21
$ options ->shouldReceive ( 'is_excluded ' )->andReturn ( $ exluded );
21
22
22
23
Functions \expect ( 'msls_options ' )->zeroOrMoreTimes ()->andReturn ( $ options );
23
-
24
24
Functions \expect ( 'apply_filters ' )->atLeast ()->once ();
25
-
26
25
Functions \expect ( 'get_taxonomies ' )->atLeast ()->once ()->andReturn ( array () );
27
- Functions \expect ( 'get_query_var ' )->atLeast ()->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
28
26
29
27
return new MslsTaxonomy ();
30
28
}
@@ -37,27 +35,44 @@ public function test_acl_request_included(): void {
37
35
38
36
Functions \when ( 'get_taxonomy ' )->justReturn ( $ taxonomy );
39
37
Functions \when ( 'current_user_can ' )->justReturn ( true );
38
+ Functions \expect ( 'get_query_var ' )->twice ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
40
39
41
40
$ this ->assertEquals ( 'category ' , $ this ->get_test ()->acl_request () );
42
41
}
43
42
44
43
public function test_acl_request_excluded (): void {
44
+ Functions \expect ( 'get_query_var ' )->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
45
45
$ this ->assertEquals ( '' , $ this ->get_test ( true )->acl_request () );
46
46
}
47
47
48
48
public function test_get_post_type (): void {
49
+ Functions \expect ( 'get_query_var ' )->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
49
50
$ this ->assertEquals ( '' , $ this ->get_test ()->get_post_type () );
50
51
}
51
52
52
53
public function test_is_post_type (): void {
54
+ Functions \expect ( 'get_query_var ' )->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
53
55
$ this ->assertFalse ( $ this ->get_test ()->is_post_type () );
54
56
}
55
57
56
58
public function test_is_taxonomy (): void {
59
+ Functions \expect ( 'get_query_var ' )->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
57
60
$ this ->assertTrue ( $ this ->get_test ()->is_taxonomy () );
58
61
}
59
62
60
- public function test_get_request (): void {
63
+ public function test_get_request_empty (): void {
64
+ Functions \expect ( 'get_query_var ' )->twice ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
65
+ Functions \expect ( 'filter_has_var ' )->twice ()->with ( INPUT_GET , MslsFields::FIELD_TAXONOMY )->andReturn ( false );
66
+
61
67
$ this ->assertEquals ( 'category ' , $ this ->get_test ()->get_request () );
62
68
}
69
+
70
+ public function test_get_request_not_empty (): void {
71
+ $ taxonomy = 'a_random_taxonomy ' ;
72
+
73
+ Functions \expect ( 'filter_has_var ' )->twice ()->with ( INPUT_GET , MslsFields::FIELD_TAXONOMY )->andReturn ( true );
74
+ Functions \expect ( 'filter_input ' )->twice ()->with ( INPUT_GET , MslsFields::FIELD_TAXONOMY , FILTER_SANITIZE_FULL_SPECIAL_CHARS )->andReturn ( $ taxonomy );
75
+
76
+ $ this ->assertEquals ( $ taxonomy , $ this ->get_test ()->get_request () );
77
+ }
63
78
}
0 commit comments