@@ -32,6 +32,8 @@ protected function setUp(): void {
32
32
33
33
$ collection = \Mockery::mock ( MslsBlogCollection::class );
34
34
$ collection ->shouldReceive ( 'get ' )->andReturn ( array ( $ blog ) );
35
+ $ collection ->shouldReceive ( 'has_current_blog ' )->andReturnTrue ();
36
+ $ collection ->shouldReceive ( 'get_current_blog ' )->andReturn ( $ blog );
35
37
36
38
$ this ->test = new MslsMetaBox ( $ options , $ collection );
37
39
}
@@ -123,7 +125,6 @@ public static function add_data_provider(): array {
123
125
124
126
/**
125
127
* @dataProvider add_data_provider
126
- * @doesNotPerformAssertions
127
128
*/
128
129
public function test_add ( $ post_type , $ content_import , $ autocomplete ) {
129
130
$ options = \Mockery::mock ( MslsOptions::class );
@@ -137,6 +138,7 @@ public function test_add( $post_type, $content_import, $autocomplete ) {
137
138
Functions \expect ( 'msls_options ' )->atLeast ()->once ()->andReturn ( $ options );
138
139
Functions \expect ( 'msls_post_type ' )->once ()->andReturn ( $ post_type );
139
140
141
+ $ this ->expectNotToPerformAssertions ();
140
142
$ this ->test ->add ();
141
143
}
142
144
@@ -267,12 +269,25 @@ public function test_render_input_only_one_blog() {
267
269
$ this ->test ->render_input ();
268
270
}
269
271
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 () {
274
280
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 ();
275
289
290
+ $ this ->expectNotToPerformAssertions ();
276
291
$ this ->test ->set ( 13 );
277
292
}
278
293
}
0 commit comments