@@ -92,86 +92,62 @@ public function test_can_set_up_with_failing_filesystem() {
9292 $ this ->assertFalse ( $ runtime_setup ->can_set_up () );
9393 }
9494
95- public function test_before_runtime_setup_action_fires () {
95+ public function test_set_up_fires_setup_environment_hooks () {
9696 $ this ->set_up_mock_filesystem ();
9797
98- $ fired = false ;
99- $ context = null ;
98+ $ calls = array () ;
99+
100100 add_action (
101101 'wp_plugin_check_before_runtime_setup ' ,
102- function ( $ ctx ) use ( &$ fired , &$ context ) {
103- $ fired = true ;
104- $ context = $ ctx ;
102+ static function ( $ environment_setup ) use ( &$ calls ) {
103+ $ calls [] = array ( 'before ' , $ environment_setup );
105104 }
106105 );
107106
108- $ runtime_setup = new Runtime_Environment_Setup ();
109- $ runtime_setup ->set_up ();
110-
111- $ this ->assertTrue ( $ fired );
112- $ this ->assertIsArray ( $ context );
113- $ this ->assertArrayHasKey ( 'early_exit ' , $ context );
114- $ this ->assertFalse ( $ context ['early_exit ' ] );
115- }
116-
117- public function test_after_runtime_setup_action_fires () {
118- $ this ->set_up_mock_filesystem ();
119-
120- $ fired = false ;
121- $ context = null ;
122107 add_action (
123108 'wp_plugin_check_after_runtime_setup ' ,
124- function ( $ ctx ) use ( &$ fired , &$ context ) {
125- $ fired = true ;
126- $ context = $ ctx ;
109+ static function ( $ environment_setup ) use ( &$ calls ) {
110+ $ calls [] = array ( 'after ' , $ environment_setup );
127111 }
128112 );
129113
130114 $ runtime_setup = new Runtime_Environment_Setup ();
131115 $ runtime_setup ->set_up ();
132116
133- $ this ->assertTrue ( $ fired );
134- $ this ->assertIsArray ( $ context );
135- $ this ->assertArrayHasKey ( 'early_exit ' , $ context );
117+ $ this ->assertCount ( 2 , $ calls );
118+ $ this ->assertSame ( 'before ' , $ calls [0 ][0 ] );
119+ $ this ->assertSame ( 'after ' , $ calls [1 ][0 ] );
120+ $ this ->assertSame ( $ runtime_setup , $ calls [0 ][1 ] );
121+ $ this ->assertSame ( $ runtime_setup , $ calls [1 ][1 ] );
136122 }
137123
138- public function test_before_runtime_cleanup_action_fires () {
139- $ fired = false ;
140- $ context = null ;
124+ public function test_clean_up_fires_cleanup_environment_hooks () {
125+ $ this ->set_up_mock_filesystem ();
126+
127+ $ calls = array ();
128+
141129 add_action (
142130 'wp_plugin_check_before_runtime_cleanup ' ,
143- function ( $ ctx ) use ( &$ fired , &$ context ) {
144- $ fired = true ;
145- $ context = $ ctx ;
131+ static function ( $ environment_setup ) use ( &$ calls ) {
132+ $ calls [] = array ( 'before ' , $ environment_setup );
146133 }
147134 );
148135
149- $ runtime_setup = new Runtime_Environment_Setup ();
150- $ runtime_setup ->clean_up ();
151-
152- $ this ->assertTrue ( $ fired );
153- $ this ->assertIsArray ( $ context );
154- $ this ->assertArrayHasKey ( 'early_exit ' , $ context );
155- $ this ->assertFalse ( $ context ['early_exit ' ] );
156- }
157-
158- public function test_after_runtime_cleanup_action_fires () {
159- $ fired = false ;
160- $ context = null ;
161136 add_action (
162137 'wp_plugin_check_after_runtime_cleanup ' ,
163- function ( $ ctx ) use ( &$ fired , &$ context ) {
164- $ fired = true ;
165- $ context = $ ctx ;
138+ static function ( $ environment_setup ) use ( &$ calls ) {
139+ $ calls [] = array ( 'after ' , $ environment_setup );
166140 }
167141 );
168142
169143 $ runtime_setup = new Runtime_Environment_Setup ();
170144 $ runtime_setup ->clean_up ();
171145
172- $ this ->assertTrue ( $ fired );
173- $ this ->assertIsArray ( $ context );
174- $ this ->assertArrayHasKey ( 'early_exit ' , $ context );
146+ $ this ->assertCount ( 2 , $ calls );
147+ $ this ->assertSame ( 'before ' , $ calls [0 ][0 ] );
148+ $ this ->assertSame ( 'after ' , $ calls [1 ][0 ] );
149+ $ this ->assertSame ( $ runtime_setup , $ calls [0 ][1 ] );
150+ $ this ->assertSame ( $ runtime_setup , $ calls [1 ][1 ] );
175151 }
176152
177153 public function test_clean_up () {
0 commit comments