Skip to content

Commit 27ce381

Browse files
committed
Fix
1 parent 97005f9 commit 27ce381

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

includes/MslsPlugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function __construct( MslsOptions $options ) {
3838
* @return MslsPlugin
3939
*/
4040
public static function init() {
41-
$obj = new self( msls_options() );
41+
$obj = new self( MslsOptions::instance() );
4242

4343
add_action( 'plugins_loaded', [ $obj, 'init_i18n_support' ] );
4444

tests/TestMslsMain.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
class TestMslsMain extends MslsUnitTestCase {
1212

13-
public function get_sut(): MslsMain {
14-
Functions\when( 'get_options' )->justReturn( [] );
13+
protected function setUp(): void {
14+
parent::setUp();
1515

1616
$options = \Mockery::mock( MslsOptions::class );
1717

@@ -21,35 +21,34 @@ public function get_sut(): MslsMain {
2121
$collection = \Mockery::mock( MslsBlogCollection::class );
2222
$collection->shouldReceive( 'get_current_blog' )->andReturn( $blog );
2323

24-
return new MslsMain( $options, $collection );
24+
$this->test = new MslsMain( $options, $collection );
2525
}
2626

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 ) );
3129
}
3230

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+
3337
public function test_is_autosave(): void {
3438
Functions\when( 'wp_is_post_revision' )->justReturn( true );
3539

36-
$obj = $this->get_sut();
37-
38-
$this->assertIsBool( $obj->is_autosave( 0 ) );
40+
$this->assertIsBool( $this->test->is_autosave( 0 ) );
3941
}
4042

4143
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() );
4545
}
4646

4747
public function test_debugger_string(): void {
4848
$capture = tmpfile();
4949
$backup = ini_set( 'error_log', stream_get_meta_data( $capture )['uri'] );
5050

51-
$obj = $this->get_sut();
52-
$obj->debugger( 'Test' );
51+
$this->test->debugger( 'Test' );
5352

5453
$this->assertStringContainsString( 'MSLS Debug: Test', stream_get_contents( $capture ) );
5554

@@ -60,8 +59,7 @@ public function test_debugger_object(): void {
6059
$capture = tmpfile();
6160
$backup = ini_set( 'error_log', stream_get_meta_data( $capture )['uri'] );
6261

63-
$obj = $this->get_sut();
64-
$obj->debugger( (object) [ 'test' => 'msls' ] );
62+
$this->test->debugger( (object) [ 'test' => 'msls' ] );
6563

6664
$this->assertStringContainsString( '[test] => msls', stream_get_contents( $capture ) );
6765

0 commit comments

Comments
 (0)