Skip to content

Commit ef65f15

Browse files
committed
MslsMetaBox::set tested
1 parent b657a3c commit ef65f15

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tests/phpunit/TestMslsMetaBox.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,8 @@ public function test_set_no_request() {
279279
public function test_set_with_request() {
280280
Functions\expect( 'wp_is_post_revision' )->once()->andReturn( false );
281281
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 );
282+
Functions\expect( 'wp_verify_nonce' )->once()->andReturnTrue();
283+
Functions\expect( 'current_user_can' )->once()->andReturnTrue();
285284
Functions\expect( 'get_option' )->atLeast()->once()->andReturn( array() );
286285
Functions\expect( 'delete_option' )->atLeast()->once();
287286
Functions\expect( 'switch_to_blog' )->once();
@@ -290,4 +289,14 @@ public function test_set_with_request() {
290289
$this->expectNotToPerformAssertions();
291290
$this->test->set( 13 );
292291
}
292+
293+
public function test_set_with_request_current_user_cannot() {
294+
Functions\expect( 'wp_is_post_revision' )->once()->andReturn( false );
295+
Functions\expect( 'filter_has_var' )->once()->with( INPUT_POST, MslsFields::FIELD_MSLS_NONCENAME )->andReturnTrue();
296+
Functions\expect( 'wp_verify_nonce' )->once()->andReturnTrue();
297+
Functions\expect( 'current_user_can' )->once()->andReturnFalse();
298+
299+
$this->expectNotToPerformAssertions();
300+
$this->test->set( 13 );
301+
}
293302
}

0 commit comments

Comments
 (0)