@@ -60,47 +60,31 @@ public function get_sut( array $users = array() ): MslsAdmin {
6060 return new MslsAdmin ( $ options , $ collection );
6161 }
6262
63- public function test_has_problems_no_problem (): void {
64- $ options = \Mockery::mock ( MslsOptions::class );
65- $ options ->shouldReceive ( 'get_available_languages ' )->andReturns ( array ( 'de_DE ' , 'it_IT ' ) );
66-
67- $ collection = \Mockery::mock ( MslsBlogCollection::class );
68- $ options ->shouldReceive ( 'is_empty ' )->andReturns ( false );
69-
70- $ obj = new MslsAdmin ( $ options , $ collection );
71-
72- $ this ->assertFalse ( $ obj ->has_problems () );
73- }
74-
75- public function test_has_problems_one_language (): void {
76- $ options = \Mockery::mock ( MslsOptions::class );
77- $ options ->shouldReceive ( 'get_available_languages ' )->andReturns ( array ( 'de_DE ' ) );
78-
79- $ collection = \Mockery::mock ( MslsBlogCollection::class );
80- $ options ->shouldReceive ( 'is_empty ' )->andReturns ( false );
81-
82- $ obj = new MslsAdmin ( $ options , $ collection );
83-
84- $ this ->expectOutputRegex ( '/^<div id="msls-warning" class="updated fade"><p>.*$/ ' );
85-
86- $ this ->assertTrue ( $ obj ->has_problems () );
63+ public static function has_problems_data (): array {
64+ return array (
65+ array ( array ( 'de_DE ' , 'it_IT ' ), false , '/^$/ ' ),
66+ array ( array ( 'de_DE ' ), false , '/^<div id="msls-warning" class="updated fade"><p>.*$/ ' ),
67+ array ( array (), true , '/^<div id="msls-warning" class="updated fade"><p>.*$/ ' ),
68+ );
8769 }
8870
89- public function test_has_problems_is_empty (): void {
71+ /**
72+ * @dataProvider has_problems_data
73+ */
74+ public function test_has_problems ( array $ languages , bool $ is_empty , string $ regex ): void {
9075 Functions \when ( 'get_option ' )->justReturn ( array () );
9176 Functions \when ( 'get_current_blog_id ' )->justReturn ( 1 );
9277 Functions \when ( 'admin_url ' )->justReturn ( '' );
9378
9479 $ options = \Mockery::mock ( MslsOptions::class );
95- $ options ->shouldReceive ( 'is_empty ' )->andReturns ( true );
80+ $ options ->shouldReceive ( 'get_available_languages ' )->zeroOrMoreTimes ()-> andReturns ( $ languages );
9681
9782 $ collection = \Mockery::mock ( MslsBlogCollection::class );
83+ $ options ->shouldReceive ( 'is_empty ' )->once ()->andReturns ( $ is_empty );
9884
99- $ obj = new MslsAdmin ( $ options , $ collection );
100-
101- $ this ->expectOutputRegex ( '/^<div id="msls-warning" class="updated fade"><p>.*$/ ' );
85+ $ this ->expectOutputRegex ( $ regex );
10286
103- $ this -> assertTrue ( $ obj ->has_problems () );
87+ ( new MslsAdmin ( $ options , $ collection ) ) ->has_problems ();
10488 }
10589
10690 public function test_subsubsub (): void {
0 commit comments