@@ 39-52 (lines=14) @@ | ||
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 | ( new Shutdown_Handler( $this->plugins_handler, array(), false ) )(); |
|
52 | } |
|
53 | ||
54 | /** |
|
55 | * Tests that the shutdown handler does not update the cache if it has not changed. |
|
@@ 57-69 (lines=13) @@ | ||
54 | /** |
|
55 | * Tests that the shutdown handler does not update the cache if it has not changed. |
|
56 | */ |
|
57 | public function test_shutdown_does_not_save_unchanged_cache() { |
|
58 | $this->plugins_handler->expects( $this->once() ) |
|
59 | ->method( 'get_active_plugins' ) |
|
60 | ->with( false, true ) |
|
61 | ->willReturn( array( TEST_PLUGIN_DIR ) ); |
|
62 | $this->plugins_handler->expects( $this->never() ) |
|
63 | ->method( 'cache_plugins' ); |
|
64 | ||
65 | // Mark that the plugins have been loaded so that we can perform a safe shutdown. |
|
66 | do_action( 'plugins_loaded' ); |
|
67 | ||
68 | ( new Shutdown_Handler( $this->plugins_handler, array( TEST_PLUGIN_DIR ), false ) )(); |
|
69 | } |
|
70 | ||
71 | /** |
|
72 | * Tests that shutting down early empties the cache. |
|
@@ 87-100 (lines=14) @@ | ||
84 | /** |
|
85 | * Tests that expected exceptions thrown during shutdown aren't propogated. |
|
86 | */ |
|
87 | public function test_shutdown_handles_exceptions() { |
|
88 | $this->plugins_handler->expects( $this->once() ) |
|
89 | ->method( 'get_active_plugins' ) |
|
90 | ->with( false, true ) |
|
91 | ->willThrowException( new \RuntimeException() ); |
|
92 | $this->plugins_handler->expects( $this->once() ) |
|
93 | ->method( 'cache_plugins' ) |
|
94 | ->with( array() ); |
|
95 | ||
96 | // Mark that the plugins have been loaded so that we can perform a safe shutdown. |
|
97 | do_action( 'plugins_loaded' ); |
|
98 | ||
99 | ( new Shutdown_Handler( $this->plugins_handler, array( TEST_PLUGIN_DIR ), false ) )(); |
|
100 | } |
|
101 | } |
|
102 |