55use Brain \Monkey \Functions ;
66
77use lloc \Msls \MslsOptionsQuery ;
8+ use lloc \Msls \MslsOptionsQueryAuthor ;
9+ use lloc \Msls \MslsOptionsQueryDay ;
10+ use lloc \Msls \MslsOptionsQueryMonth ;
11+ use lloc \Msls \MslsOptionsQueryPostType ;
12+ use lloc \Msls \MslsOptionsQueryYear ;
813
914/**
1015 * TestMslsOptionsQuery
1116 */
1217class TestMslsOptionsQuery extends MslsUnitTestCase {
1318
14- public function test_create (): void {
19+ public function test_create_is_day (): void {
20+ Functions \expect ( 'is_day ' )->once ()->andReturn ( true );
21+ Functions \expect ( 'get_query_var ' )->times ( 3 )->andReturnValues ( array ( 1969 , 6 , 26 ) );
22+ Functions \expect ( 'get_option ' )->once ();
23+
24+ $ this ->assertInstanceOf ( MslsOptionsQueryDay::class, MslsOptionsQuery::create () );
25+ }
26+ public function test_create_is_month (): void {
27+ Functions \expect ( 'is_day ' )->once ()->andReturn ( false );
28+ Functions \expect ( 'is_month ' )->once ()->andReturn ( true );
29+ Functions \expect ( 'get_query_var ' )->twice ()->andReturnValues ( array ( 1969 , 6 ) );
30+ Functions \expect ( 'get_option ' )->once ();
31+
32+ $ this ->assertInstanceOf ( MslsOptionsQueryMonth::class, MslsOptionsQuery::create () );
33+ }
34+
35+ public function test_create_is_year (): void {
36+ Functions \expect ( 'is_day ' )->once ()->andReturn ( false );
37+ Functions \expect ( 'is_month ' )->once ()->andReturn ( false );
38+ Functions \expect ( 'is_year ' )->once ()->andReturn ( true );
39+ Functions \expect ( 'get_query_var ' )->once ()->andReturn ( 1969 );
40+ Functions \expect ( 'get_option ' )->once ();
41+
42+ $ this ->assertInstanceOf ( MslsOptionsQueryYear::class, MslsOptionsQuery::create () );
43+ }
44+
45+ public function test_create_is_author (): void {
46+ Functions \expect ( 'is_day ' )->once ()->andReturn ( false );
47+ Functions \expect ( 'is_month ' )->once ()->andReturn ( false );
48+ Functions \expect ( 'is_year ' )->once ()->andReturn ( false );
49+ Functions \expect ( 'is_author ' )->once ()->andReturn ( true );
50+ Functions \expect ( 'get_queried_object_id ' )->once ()->andReturn ( 42 );
51+ Functions \expect ( 'get_option ' )->once ();
52+
53+ $ this ->assertInstanceOf ( MslsOptionsQueryAuthor::class, MslsOptionsQuery::create () );
54+ }
55+
56+ public function test_create_is_post_type_archive (): void {
57+ Functions \expect ( 'is_day ' )->once ()->andReturn ( false );
58+ Functions \expect ( 'is_month ' )->once ()->andReturn ( false );
59+ Functions \expect ( 'is_year ' )->once ()->andReturn ( false );
60+ Functions \expect ( 'is_author ' )->once ()->andReturn ( false );
61+ Functions \expect ( 'is_post_type_archive ' )->once ()->andReturn ( true );
62+ Functions \expect ( 'get_query_var ' )->once ()->andReturn ( 'book ' );
63+ Functions \expect ( 'get_option ' )->once ();
64+
65+ $ this ->assertInstanceOf ( MslsOptionsQueryPostType::class, MslsOptionsQuery::create () );
66+ }
67+
68+ public function test_create_is_null (): void {
1569 Functions \expect ( 'is_day ' )->once ()->andReturn ( false );
1670 Functions \expect ( 'is_month ' )->once ()->andReturn ( false );
1771 Functions \expect ( 'is_year ' )->once ()->andReturn ( false );
@@ -24,16 +78,15 @@ public function test_create(): void {
2478 public function test_current_get_postlink (): void {
2579 $ home_url = 'https://example.org/ ' ;
2680
27- Functions \expect ( 'get_option ' )->once ()->andReturn ( [ 'de_DE ' => 42 ] );
81+ Functions \expect ( 'get_option ' )->once ()->andReturn ( array ( 'de_DE ' => 42 ) );
2882 Functions \expect ( 'home_url ' )->once ()->andReturn ( $ home_url );
2983
3084 $ this ->assertEquals ( $ home_url , ( new MslsOptionsQuery () )->get_postlink ( 'de_DE ' ) );
3185 }
3286
3387 public function test_non_existent_get_postlink (): void {
34- Functions \expect ( 'get_option ' )->once ()->andReturn ( [ 'de_DE ' => 42 ] );
88+ Functions \expect ( 'get_option ' )->once ()->andReturn ( array ( 'de_DE ' => 42 ) );
3589
3690 $ this ->assertEquals ( '' , ( new MslsOptionsQuery () )->get_postlink ( 'fr_FR ' ) );
3791 }
38-
39- }
92+ }
0 commit comments