@@ -17,57 +17,61 @@ class TestMslsBlogCollection extends MslsUnitTestCase {
1717	protected  function  setUp (): void  {
1818		parent ::setUp (); // TODO: Change the autogenerated stub 
1919
20-         $ options  = \Mockery::mock ( MslsOptions::class );
21-         $ options ->shouldReceive ( 'get_order '  )->andReturn ( 'description '  );
22-         $ options ->shouldReceive ( 'is_excluded '  )->andReturn ( false  );
23-         $ options ->shouldReceive ( 'has_value '  )->andReturn ( false  );
24- 
25-         Functions \expect ( 'msls_options '  )->atLeast ()->once ()->andReturn ( $ options  );
26- 
27-         $ a  = \Mockery::mock ( MslsBlog::class );
28-         $ b  = \Mockery::mock ( MslsBlog::class );
29-         $ c  = \Mockery::mock ( MslsBlog::class );
30- 
31-         $ a ->userblog_id  = 1 ;
32-         $ b ->userblog_id  = 2 ;
33-         $ c ->userblog_id  = 3 ;
34- 
35-         Functions \expect ( 'get_current_blog_id '  )->atLeast ()->once ()->andReturn ( 1  );
36- 		Functions \expect ( 'get_users '  )->atLeast ()->once ()->andReturn ( [] );
37- 		Functions \expect ( 'get_blogs_of_user '  )->atLeast ()->once ()->andReturn ( [ $ a , $ b , $ c  ] );
38- 
39- 		Functions \expect ( 'get_blog_option '  )->atLeast ()->once ()->andReturnUsing ( function  ( $ blog_id , $ option  ) {
40- 			$ wplang  = [
41- 				1  => 'de_DE ' ,
42- 				2  => 'it_IT ' ,
43- 				3  => 'fr_FR ' ,
44- 			];
45- 
46- 			$ msls  = [
47- 				1  => [ 'description '  => 'Deutsch '  ],
48- 				2  => [ 'description '  => 'Italiano '  ],
49- 				3  => [ 'description '  => 'Français '  ],
50- 			];
51- 
52- 			switch  ( $ option  ) {
53- 				case  'active_plugins ' :
54- 					$ value  = in_array ( $ blog_id , [ 1 , 2  ]
55- 					) ? [ 'multisite-language-switcher/MultisiteLanguageSwitcher.php '  ] : [];
56- 					break ;
57- 				case  'WPLANG ' :
58- 					$ value  = $ wplang [ $ blog_id  ] ?? false ;
59- 					break ;
60- 				case  'msls ' :
61- 					$ value  = $ msls [ $ blog_id  ] ?? false ;
62- 					break ;
20+ 		$ options  = \Mockery::mock ( MslsOptions::class );
21+ 		$ options ->shouldReceive ( 'get_order '  )->andReturn ( 'description '  );
22+ 		$ options ->shouldReceive ( 'is_excluded '  )->andReturn ( false  );
23+ 		$ options ->shouldReceive ( 'has_value '  )->andReturn ( false  );
24+ 
25+ 		Functions \expect ( 'msls_options '  )->atLeast ()->once ()->andReturn ( $ options  );
26+ 
27+ 		$ a  = \Mockery::mock ( MslsBlog::class );
28+ 		$ b  = \Mockery::mock ( MslsBlog::class );
29+ 		$ c  = \Mockery::mock ( MslsBlog::class );
30+ 
31+ 		$ a ->userblog_id  = 1 ;
32+ 		$ b ->userblog_id  = 2 ;
33+ 		$ c ->userblog_id  = 3 ;
34+ 
35+ 		Functions \expect ( 'get_current_blog_id '  )->atLeast ()->once ()->andReturn ( 1  );
36+ 		Functions \expect ( 'get_users '  )->atLeast ()->once ()->andReturn ( array () );
37+ 		Functions \expect ( 'get_blogs_of_user '  )->atLeast ()->once ()->andReturn ( array ( $ a , $ b , $ c  ) );
38+ 
39+ 		Functions \expect ( 'get_blog_option '  )->atLeast ()->once ()->andReturnUsing (
40+ 			function  ( $ blog_id , $ option  ) {
41+ 				$ wplang  = array (
42+ 					1  => 'de_DE ' ,
43+ 					2  => 'it_IT ' ,
44+ 					3  => 'fr_FR ' ,
45+ 				);
46+ 
47+ 				$ msls  = array (
48+ 					1  => array ( 'description '  => 'Deutsch '  ),
49+ 					2  => array ( 'description '  => 'Italiano '  ),
50+ 					3  => array ( 'description '  => 'Français '  ),
51+ 				);
52+ 
53+ 				switch  ( $ option  ) {
54+ 					case  'active_plugins ' :
55+ 						$ value  = in_array (
56+ 							$ blog_id ,
57+ 							array ( 1 , 2  )
58+ 						) ? array ( 'multisite-language-switcher/MultisiteLanguageSwitcher.php '  ) : array ();
59+ 						break ;
60+ 					case  'WPLANG ' :
61+ 						$ value  = $ wplang [ $ blog_id  ] ?? false ;
62+ 						break ;
63+ 					case  'msls ' :
64+ 							$ value  = $ msls [ $ blog_id  ] ?? false ;
65+ 						break ;
66+ 				}
67+ 
68+ 				return  $ value ;
6369			}
64- 
65- 			return  $ value ;
66- 		} );
70+ 		);
6771	}
6872
6973	public  function  test_get_configured_blog_description_empty (): void  {
70- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
74+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
7175
7276		$ obj  = new  MslsBlogCollection ();
7377
@@ -81,7 +85,7 @@ public function test_get_configured_blog_description_empty(): void {
8185	}
8286
8387	public  function  test_get_blogs_of_reference_user (): void  {
84- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
88+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
8589
8690		$ options  = \Mockery::mock ( MslsOptions::class );
8791		$ options ->shouldReceive ( 'has_value '  )->andReturn ( true  );
@@ -92,23 +96,23 @@ public function test_get_blogs_of_reference_user(): void {
9296	}
9397
9498	public  function  test_get_current_blog_id (): void  {
95- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
99+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
96100
97101		$ obj  = new  MslsBlogCollection ();
98102
99103		$ this  ->assertIsInt ( $ obj ->get_current_blog_id () );
100104	}
101105
102106	public  function  test_has_current_blog (): void  {
103- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
107+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
104108
105109		$ obj  = new  MslsBlogCollection ();
106110
107111		$ this  ->assertIsBool ( $ obj ->has_current_blog () );
108112	}
109113
110114	public  function  test_is_current_blog_true (): void  {
111- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
115+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
112116
113117		$ obj  = new  MslsBlogCollection ();
114118
@@ -119,7 +123,7 @@ public function test_is_current_blog_true(): void {
119123	}
120124
121125	public  function  test_is_current_blog_false (): void  {
122- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
126+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
123127
124128		$ obj  = new  MslsBlogCollection ();
125129
@@ -130,16 +134,25 @@ public function test_is_current_blog_false(): void {
130134	}
131135
132136	public  function  test_get_objects (): void  {
133- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
137+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
134138
135139		$ obj  = new  MslsBlogCollection ();
136140
137141		$ this  ->assertIsArray ( $ obj ->get_objects () );
138142	}
139143
144+ 	public  function  test_get_object (): void  {
145+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array () );
146+ 
147+ 		$ obj  = new  MslsBlogCollection ();
148+ 
149+ 		$ this  ->assertInstanceOf ( MslsBlog::class, $ obj ->get_object ( 1  ) );
150+ 		$ this  ->assertNull ( $ obj ->get_object ( 4  ) );
151+ 	}
152+ 
140153	public  function  test_is_plugin_active_networkwide (): void  {
141154		Functions \expect ( 'get_site_option '  )->once ()->andReturn (
142- 			[  'multisite-language-switcher/MultisiteLanguageSwitcher.php '  => 'Multisite Language Switcher '  ] 
155+ 			array (  'multisite-language-switcher/MultisiteLanguageSwitcher.php '  => 'Multisite Language Switcher '  ) 
143156		);
144157
145158		$ obj  = new  MslsBlogCollection ();
@@ -148,7 +161,7 @@ public function test_is_plugin_active_networkwide(): void {
148161	}
149162
150163	public  function  test_is_plugin_active (): void  {
151- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
164+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
152165
153166		$ obj  = new  MslsBlogCollection ();
154167
@@ -159,23 +172,23 @@ public function test_is_plugin_active(): void {
159172	}
160173
161174	public  function  test_get_plugin_active_blogs (): void  {
162- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
175+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
163176
164177		$ obj  = new  MslsBlogCollection ();
165178
166179		$ this  ->assertIsArray ( $ obj ->get_plugin_active_blogs () );
167180	}
168181
169182	public  function  test_get (): void  {
170- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
183+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
171184
172185		$ obj  = new  MslsBlogCollection ();
173186
174187		$ this  ->assertIsArray ( $ obj ->get () );
175188	}
176189
177190	public  function  test_get_filtered (): void  {
178- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
191+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
179192
180193		$ obj  = new  MslsBlogCollection ();
181194
@@ -184,23 +197,23 @@ public function test_get_filtered(): void {
184197	}
185198
186199	public  function  test_get_users (): void  {
187- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
200+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
188201
189202		$ obj  = new  MslsBlogCollection ();
190203
191204		$ this  ->assertIsArray ( $ obj ->get_users () );
192205	}
193206
194207	public  function  test_get_current_blog (): void  {
195- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
208+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
196209
197210		$ obj  = new  MslsBlogCollection ();
198211
199212		$ this  ->assertInstanceOf ( MslsBlog::class, $ obj ->get_current_blog () );
200213	}
201214
202215	public  function  test_get_blog_language (): void  {
203- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
216+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
204217
205218		$ obj  = new  MslsBlogCollection ();
206219
@@ -212,7 +225,7 @@ public function test_get_blog_language(): void {
212225	}
213226
214227	public  function  test_get_blog_id (): void  {
215- 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( []  );
228+ 		Functions \expect ( 'get_site_option '  )->once ()->andReturn ( array ()  );
216229
217230		$ obj  = new  MslsBlogCollection ();
218231
@@ -221,5 +234,4 @@ public function test_get_blog_id(): void {
221234
222235		$ this  ->assertNull ( $ obj ->get_blog_id ( 'fr_FR '  ) );
223236	}
224- 
225237}
0 commit comments