@@ -326,6 +326,67 @@ public function test_is_requirements_not_fulfilled_with_mslsoptionspost(): void
326326 $ this ->assertTrue ( $ test ->is_requirements_not_fulfilled ( $ mydata , true , 'de_DE ' ) );
327327 }
328328
329+ public function test_get_alternate_links_empty_url (): void {
330+ $ blogs = array ();
331+
332+ $ a = \Mockery::mock ( MslsBlog::class );
333+ $ a ->shouldReceive ( 'get_alpha2 ' )->andReturn ( 'de ' );
334+ $ a ->shouldReceive ( 'get_language ' )->andReturn ( 'de_DE ' );
335+ $ a ->shouldReceive ( 'get_url ' )->andReturn ( '' );
336+
337+ $ blogs [] = $ a ;
338+
339+ $ collection = \Mockery::mock ( MslsBlogCollection::class );
340+ $ collection ->shouldReceive ( 'get_objects ' )->andReturn ( $ blogs );
341+
342+ Functions \expect ( 'msls_blog_collection ' )->once ()->andReturn ( $ collection );
343+ Functions \expect ( 'is_admin ' )->once ()->andReturn ( false );
344+ Functions \expect ( 'is_front_page ' )->once ()->andReturn ( false );
345+ Functions \expect ( 'is_search ' )->once ()->andReturn ( false );
346+ Functions \expect ( 'is_404 ' )->once ()->andReturn ( false );
347+ Functions \expect ( 'is_category ' )->once ()->andReturn ( false );
348+ Functions \expect ( 'is_tag ' )->once ()->andReturn ( false );
349+ Functions \expect ( 'is_tax ' )->once ()->andReturn ( false );
350+ Functions \expect ( 'is_date ' )->once ()->andReturn ( false );
351+ Functions \expect ( 'is_author ' )->once ()->andReturn ( false );
352+ Functions \expect ( 'is_post_type_archive ' )->once ()->andReturn ( false );
353+ Functions \expect ( 'get_queried_object_id ' )->once ()->andReturn ( 42 );
354+ Functions \expect ( 'get_option ' )->once ()->andReturn ( array () );
355+
356+ $ test = $ this ->MslsOutputFactory ();
357+
358+ $ this ->assertEquals ( '' , $ test ->get_alternate_links () );
359+ }
360+
361+ public function test_get_skips_empty_url (): void {
362+ $ blog = \Mockery::mock ( MslsBlog::class );
363+ $ blog ->shouldReceive ( 'get_language ' )->andReturn ( 'de_DE ' );
364+ $ blog ->shouldReceive ( 'get_description ' )->andReturn ( 'Deutsch ' );
365+ $ blog ->userblog_id = 2 ;
366+
367+ $ options = \Mockery::mock ( MslsOptions::class );
368+ $ options ->shouldReceive ( 'get_flag_url ' )->once ()->andReturn ( 'https://msls.co/wp-content/plugins/msls/flags/de.png ' );
369+
370+ $ collection = \Mockery::mock ( MslsBlogCollection::class );
371+ $ collection ->shouldReceive ( 'get_filtered ' )->andReturn ( array ( $ blog ) );
372+ $ collection ->shouldReceive ( 'is_current_blog ' )->andReturn ( false );
373+
374+ Functions \expect ( 'is_admin ' )->atLeast ()->once ()->andReturn ( false );
375+ Functions \expect ( 'is_front_page ' )->atLeast ()->once ()->andReturn ( false );
376+ Functions \expect ( 'is_search ' )->andReturn ( false );
377+ Functions \expect ( 'is_404 ' )->andReturn ( false );
378+ Functions \expect ( 'is_category ' )->atLeast ()->once ()->andReturn ( true );
379+ Functions \expect ( 'is_tag ' )->andReturn ( false );
380+ Functions \expect ( 'is_tax ' )->andReturn ( false );
381+ Functions \expect ( 'is_woocommerce ' )->andReturn ( false );
382+ Functions \expect ( 'get_queried_object_id ' )->atLeast ()->once ()->andReturn ( 42 );
383+ Functions \expect ( 'get_option ' )->atLeast ()->once ()->andReturn ( array () );
384+ Functions \expect ( 'switch_to_blog ' )->once ();
385+ Functions \expect ( 'restore_current_blog ' )->once ();
386+
387+ $ this ->assertEquals ( array (), ( new MslsOutput ( $ options , $ collection ) )->get ( 0 ) );
388+ }
389+
329390 public function test_init (): void {
330391 Functions \expect ( '_deprecated_function ' )->once ();
331392
0 commit comments