5
5
use Brain \Monkey \Functions ;
6
6
7
7
use 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 ;
8
13
9
14
/**
10
15
* TestMslsOptionsQuery
11
16
*/
12
17
class TestMslsOptionsQuery extends MslsUnitTestCase {
13
18
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 {
15
69
Functions \expect ( 'is_day ' )->once ()->andReturn ( false );
16
70
Functions \expect ( 'is_month ' )->once ()->andReturn ( false );
17
71
Functions \expect ( 'is_year ' )->once ()->andReturn ( false );
@@ -24,16 +78,15 @@ public function test_create(): void {
24
78
public function test_current_get_postlink (): void {
25
79
$ home_url = 'https://example.org/ ' ;
26
80
27
- Functions \expect ( 'get_option ' )->once ()->andReturn ( [ 'de_DE ' => 42 ] );
81
+ Functions \expect ( 'get_option ' )->once ()->andReturn ( array ( 'de_DE ' => 42 ) );
28
82
Functions \expect ( 'home_url ' )->once ()->andReturn ( $ home_url );
29
83
30
84
$ this ->assertEquals ( $ home_url , ( new MslsOptionsQuery () )->get_postlink ( 'de_DE ' ) );
31
85
}
32
86
33
87
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 ) );
35
89
36
90
$ this ->assertEquals ( '' , ( new MslsOptionsQuery () )->get_postlink ( 'fr_FR ' ) );
37
91
}
38
-
39
- }
92
+ }
0 commit comments