10
10
11
11
class TestMslsMain extends MslsUnitTestCase {
12
12
13
- public function get_sut (): MslsMain {
14
- Functions \when ( ' get_options ' )-> justReturn ( [] );
13
+ protected function setUp (): void {
14
+ parent :: setUp ( );
15
15
16
16
$ options = \Mockery::mock ( MslsOptions::class );
17
17
@@ -21,35 +21,34 @@ public function get_sut(): MslsMain {
21
21
$ collection = \Mockery::mock ( MslsBlogCollection::class );
22
22
$ collection ->shouldReceive ( 'get_current_blog ' )->andReturn ( $ blog );
23
23
24
- return new MslsMain ( $ options , $ collection );
24
+ $ this -> test = new MslsMain ( $ options , $ collection );
25
25
}
26
26
27
- public function test_get_input_array (): void {
28
- $ obj = $ this ->get_sut ();
29
-
30
- $ this ->assertIsArray ( $ obj ->get_input_array ( 0 ) );
27
+ public function test_get_input_array_empty (): void {
28
+ $ this ->assertEquals ( [ 'de_DE ' => 0 ], $ this ->test ->get_input_array ( 0 ) );
31
29
}
32
30
31
+ public function test_get_input_array (): void {
32
+ Functions \when ('filter_input_array ' , );
33
+
34
+ $ this ->assertEquals ( [ 'de_DE ' => 1 ], $ this ->test ->get_input_array ( 1 ) );
35
+ }
36
+
33
37
public function test_is_autosave (): void {
34
38
Functions \when ( 'wp_is_post_revision ' )->justReturn ( true );
35
39
36
- $ obj = $ this ->get_sut ();
37
-
38
- $ this ->assertIsBool ( $ obj ->is_autosave ( 0 ) );
40
+ $ this ->assertIsBool ( $ this ->test ->is_autosave ( 0 ) );
39
41
}
40
42
41
43
public function test_verify_nonce (): void {
42
- $ obj = $ this ->get_sut ();
43
-
44
- $ this ->assertFalse ( $ obj ->verify_nonce () );
44
+ $ this ->assertFalse ( $ this ->test ->verify_nonce () );
45
45
}
46
46
47
47
public function test_debugger_string (): void {
48
48
$ capture = tmpfile ();
49
49
$ backup = ini_set ( 'error_log ' , stream_get_meta_data ( $ capture )['uri ' ] );
50
50
51
- $ obj = $ this ->get_sut ();
52
- $ obj ->debugger ( 'Test ' );
51
+ $ this ->test ->debugger ( 'Test ' );
53
52
54
53
$ this ->assertStringContainsString ( 'MSLS Debug: Test ' , stream_get_contents ( $ capture ) );
55
54
@@ -60,8 +59,7 @@ public function test_debugger_object(): void {
60
59
$ capture = tmpfile ();
61
60
$ backup = ini_set ( 'error_log ' , stream_get_meta_data ( $ capture )['uri ' ] );
62
61
63
- $ obj = $ this ->get_sut ();
64
- $ obj ->debugger ( (object ) [ 'test ' => 'msls ' ] );
62
+ $ this ->test ->debugger ( (object ) [ 'test ' => 'msls ' ] );
65
63
66
64
$ this ->assertStringContainsString ( '[test] => msls ' , stream_get_contents ( $ capture ) );
67
65
0 commit comments