Skip to content

Commit b657a3c

Browse files
committed
PHPStan issues addressed
1 parent fadfb7c commit b657a3c

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

includes/MslsRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static function get_config( string $name ): array {
2020
public static function has_var( string $name, ?int $input_type = null ): bool {
2121
if ( null === $input_type ) {
2222
try {
23-
list($input_type, ) = self::get_config( $name );
23+
list( $input_type, ) = self::get_config( $name );
2424
} catch ( \InvalidArgumentException $e ) {
2525
return false;
2626
}

tests/phpunit/TestMslsMetaBox.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ protected function setUp(): void {
3232

3333
$collection = \Mockery::mock( MslsBlogCollection::class );
3434
$collection->shouldReceive( 'get' )->andReturn( array( $blog ) );
35+
$collection->shouldReceive( 'has_current_blog' )->andReturnTrue();
36+
$collection->shouldReceive( 'get_current_blog' )->andReturn( $blog );
3537

3638
$this->test = new MslsMetaBox( $options, $collection );
3739
}
@@ -123,7 +125,6 @@ public static function add_data_provider(): array {
123125

124126
/**
125127
* @dataProvider add_data_provider
126-
* @doesNotPerformAssertions
127128
*/
128129
public function test_add( $post_type, $content_import, $autocomplete ) {
129130
$options = \Mockery::mock( MslsOptions::class );
@@ -137,6 +138,7 @@ public function test_add( $post_type, $content_import, $autocomplete ) {
137138
Functions\expect( 'msls_options' )->atLeast()->once()->andReturn( $options );
138139
Functions\expect( 'msls_post_type' )->once()->andReturn( $post_type );
139140

141+
$this->expectNotToPerformAssertions();
140142
$this->test->add();
141143
}
142144

@@ -267,12 +269,25 @@ public function test_render_input_only_one_blog() {
267269
$this->test->render_input();
268270
}
269271

270-
/**
271-
* @doesNotPerformAssertions
272-
*/
273-
public function test_set() {
272+
public function test_set_no_request() {
273+
Functions\expect( 'wp_is_post_revision' )->once()->andReturn( false );
274+
275+
$this->expectNotToPerformAssertions();
276+
$this->test->set( 13 );
277+
}
278+
279+
public function test_set_with_request() {
274280
Functions\expect( 'wp_is_post_revision' )->once()->andReturn( false );
281+
Functions\expect( 'filter_has_var' )->once()->with( INPUT_POST, MslsFields::FIELD_MSLS_NONCENAME )->andReturnTrue();
282+
// Functions\expect( 'filter_input' )->once()->with( INPUT_POST, MslsFields::FIELD_MSLS_NONCENAME )->andReturn( 'random_nonce' );
283+
Functions\expect( 'wp_verify_nonce' )->once()->andReturn( true );
284+
Functions\expect( 'current_user_can' )->once()->andReturn( true );
285+
Functions\expect( 'get_option' )->atLeast()->once()->andReturn( array() );
286+
Functions\expect( 'delete_option' )->atLeast()->once();
287+
Functions\expect( 'switch_to_blog' )->once();
288+
Functions\expect( 'restore_current_blog' )->once();
275289

290+
$this->expectNotToPerformAssertions();
276291
$this->test->set( 13 );
277292
}
278293
}

0 commit comments

Comments
 (0)