|
@@ 39-53 (lines=15) @@
|
| 36 |
|
/** |
| 37 |
|
* Tests that the shutdown handler caches the active plugins. |
| 38 |
|
*/ |
| 39 |
|
public function test_shutdown_caches_active_plugins() { |
| 40 |
|
$this->plugins_handler->expects( $this->once() ) |
| 41 |
|
->method( 'get_active_plugins' ) |
| 42 |
|
->with( false, true ) |
| 43 |
|
->willReturn( array( TEST_PLUGIN_DIR ) ); |
| 44 |
|
$this->plugins_handler->expects( $this->once() ) |
| 45 |
|
->method( 'cache_plugins' ) |
| 46 |
|
->with( array( TEST_PLUGIN_DIR ) ); |
| 47 |
|
|
| 48 |
|
// Mark that the plugins have been loaded so that we can perform a safe shutdown. |
| 49 |
|
do_action( 'plugins_loaded' ); |
| 50 |
|
|
| 51 |
|
$handler = new Shutdown_Handler( $this->plugins_handler, array(), false ); |
| 52 |
|
$handler(); |
| 53 |
|
} |
| 54 |
|
|
| 55 |
|
/** |
| 56 |
|
* Tests that the shutdown handler does not update the cache if it has not changed. |
|
@@ 58-71 (lines=14) @@
|
| 55 |
|
/** |
| 56 |
|
* Tests that the shutdown handler does not update the cache if it has not changed. |
| 57 |
|
*/ |
| 58 |
|
public function test_shutdown_does_not_save_unchanged_cache() { |
| 59 |
|
$this->plugins_handler->expects( $this->once() ) |
| 60 |
|
->method( 'get_active_plugins' ) |
| 61 |
|
->with( false, true ) |
| 62 |
|
->willReturn( array( TEST_PLUGIN_DIR ) ); |
| 63 |
|
$this->plugins_handler->expects( $this->never() ) |
| 64 |
|
->method( 'cache_plugins' ); |
| 65 |
|
|
| 66 |
|
// Mark that the plugins have been loaded so that we can perform a safe shutdown. |
| 67 |
|
do_action( 'plugins_loaded' ); |
| 68 |
|
|
| 69 |
|
$handler = new Shutdown_Handler( $this->plugins_handler, array( TEST_PLUGIN_DIR ), false ); |
| 70 |
|
$handler(); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
/** |
| 74 |
|
* Tests that shutting down early empties the cache. |
|
@@ 90-104 (lines=15) @@
|
| 87 |
|
/** |
| 88 |
|
* Tests that expected exceptions thrown during shutdown aren't propogated. |
| 89 |
|
*/ |
| 90 |
|
public function test_shutdown_handles_exceptions() { |
| 91 |
|
$this->plugins_handler->expects( $this->once() ) |
| 92 |
|
->method( 'get_active_plugins' ) |
| 93 |
|
->with( false, true ) |
| 94 |
|
->willThrowException( new \RuntimeException() ); |
| 95 |
|
$this->plugins_handler->expects( $this->once() ) |
| 96 |
|
->method( 'cache_plugins' ) |
| 97 |
|
->with( array() ); |
| 98 |
|
|
| 99 |
|
// Mark that the plugins have been loaded so that we can perform a safe shutdown. |
| 100 |
|
do_action( 'plugins_loaded' ); |
| 101 |
|
|
| 102 |
|
$handler = new Shutdown_Handler( $this->plugins_handler, array( TEST_PLUGIN_DIR ), false ); |
| 103 |
|
$handler(); |
| 104 |
|
} |
| 105 |
|
} |
| 106 |
|
|