33namespace lloc \MslsTests ;
44
55use Brain \Monkey \Functions ;
6+ use lloc \Msls \MslsFields ;
67use lloc \Msls \MslsOptions ;
78use lloc \Msls \MslsTaxonomy ;
89
@@ -20,11 +21,8 @@ public function get_test( bool $exluded = false ): MslsTaxonomy {
2021 $ options ->shouldReceive ( 'is_excluded ' )->andReturn ( $ exluded );
2122
2223 Functions \expect ( 'msls_options ' )->zeroOrMoreTimes ()->andReturn ( $ options );
23-
2424 Functions \expect ( 'apply_filters ' )->atLeast ()->once ();
25-
2625 Functions \expect ( 'get_taxonomies ' )->atLeast ()->once ()->andReturn ( array () );
27- Functions \expect ( 'get_query_var ' )->atLeast ()->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
2826
2927 return new MslsTaxonomy ();
3028 }
@@ -37,27 +35,44 @@ public function test_acl_request_included(): void {
3735
3836 Functions \when ( 'get_taxonomy ' )->justReturn ( $ taxonomy );
3937 Functions \when ( 'current_user_can ' )->justReturn ( true );
38+ Functions \expect ( 'get_query_var ' )->twice ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
4039
4140 $ this ->assertEquals ( 'category ' , $ this ->get_test ()->acl_request () );
4241 }
4342
4443 public function test_acl_request_excluded (): void {
44+ Functions \expect ( 'get_query_var ' )->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
4545 $ this ->assertEquals ( '' , $ this ->get_test ( true )->acl_request () );
4646 }
4747
4848 public function test_get_post_type (): void {
49+ Functions \expect ( 'get_query_var ' )->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
4950 $ this ->assertEquals ( '' , $ this ->get_test ()->get_post_type () );
5051 }
5152
5253 public function test_is_post_type (): void {
54+ Functions \expect ( 'get_query_var ' )->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
5355 $ this ->assertFalse ( $ this ->get_test ()->is_post_type () );
5456 }
5557
5658 public function test_is_taxonomy (): void {
59+ Functions \expect ( 'get_query_var ' )->once ()->with ( 'taxonomy ' )->andReturn ( 'category ' );
5760 $ this ->assertTrue ( $ this ->get_test ()->is_taxonomy () );
5861 }
5962
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+
6167 $ this ->assertEquals ( 'category ' , $ this ->get_test ()->get_request () );
6268 }
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+ }
6378}
0 commit comments