@@ 275-291 (lines=17) @@ | ||
272 | * @covers Automattic\Jetpack\Connection\Manager::delete_all_connection_tokens |
|
273 | * @throws MockEnabledException PHPUnit wasn't able to enable mock functions. |
|
274 | */ |
|
275 | public function test_delete_all_connection_tokens() { |
|
276 | $this->update_option->enable(); |
|
277 | $this->get_option->enable(); |
|
278 | $this->apply_filters->enable(); |
|
279 | $this->do_action->enable(); |
|
280 | ||
281 | ( new Plugin( 'plugin-slug-1' ) )->add( 'Plugin Name 1' ); |
|
282 | ||
283 | ( new Plugin( 'plugin-slug-2' ) )->add( 'Plugin Name 2' ); |
|
284 | ||
285 | $stub = $this->createMock( Plugin::class ); |
|
286 | $stub->method( 'is_only' ) |
|
287 | ->willReturn( false ); |
|
288 | $manager = ( new Manager() )->set_plugin_instance( $stub ); |
|
289 | ||
290 | $this->assertFalse( $manager->delete_all_connection_tokens() ); |
|
291 | } |
|
292 | ||
293 | /** |
|
294 | * Unit test for the "Disconnect from WP" functionality. |
|
@@ 299-315 (lines=17) @@ | ||
296 | * @covers Automattic\Jetpack\Connection\Manager::disconnect_site_wpcom |
|
297 | * @throws MockEnabledException PHPUnit wasn't able to enable mock functions. |
|
298 | */ |
|
299 | public function test_disconnect_site_wpcom() { |
|
300 | $this->update_option->enable(); |
|
301 | $this->get_option->enable(); |
|
302 | $this->apply_filters->enable(); |
|
303 | $this->do_action->enable(); |
|
304 | ||
305 | ( new Plugin( 'plugin-slug-1' ) )->add( 'Plugin Name 1' ); |
|
306 | ||
307 | ( new Plugin( 'plugin-slug-2' ) )->add( 'Plugin Name 2' ); |
|
308 | ||
309 | $stub = $this->createMock( Plugin::class ); |
|
310 | $stub->method( 'is_only' ) |
|
311 | ->willReturn( false ); |
|
312 | $manager = ( new Manager() )->set_plugin_instance( $stub ); |
|
313 | ||
314 | $this->assertFalse( $manager->disconnect_site_wpcom() ); |
|
315 | } |
|
316 | ||
317 | /** |
|
318 | * Mock a global function and make it return a certain value. |