@@ -168,12 +168,9 @@ public function testIncomplete(FailEvent $failEvent)
168168 */
169169 public function testEnd ()
170170 {
171+ // Pops top of stepStorage, need to add it back in after processing
171172 $ rootStep = $ this ->getLifecycle ()->getStepStorage ()->pollLast ();
172- $ formattedStep = new Step ();
173- $ formattedStep ->setName ($ rootStep ->getName ());
174- $ formattedStep ->setStart ($ rootStep ->getStart ());
175- $ formattedStep ->setStatus ($ rootStep ->getStatus ());
176-
173+ $ formattedSteps = [];
177174 $ actionGroupStepContainer = null ;
178175
179176 foreach ($ rootStep ->getSteps () as $ step ) {
@@ -185,7 +182,7 @@ public function testEnd()
185182 }
186183 // if actionGroup ended, add stack to steps
187184 if (stripos ($ step ->getName (), ActionGroupObject::ACTION_GROUP_CONTEXT_END ) !== false ) {
188- $ formattedStep -> addStep ( $ actionGroupStepContainer) ;
185+ $ formattedSteps [] = $ actionGroupStepContainer ;
189186 $ actionGroupStepContainer = null ;
190187 continue ;
191188 }
@@ -195,18 +192,25 @@ public function testEnd()
195192 if ($ step ->getStatus () !== self ::STEP_PASSED ) {
196193 // If step didn't pass, need to end action group nesting and set overall step status
197194 $ actionGroupStepContainer ->setStatus ($ step ->getStatus ());
198- $ formattedStep -> addStep ( $ actionGroupStepContainer) ;
195+ $ formattedSteps [] = $ actionGroupStepContainer ;
199196 $ actionGroupStepContainer = null ;
200197 }
201198 } else {
202199 // Add step as normal
203- $ formattedStep -> addStep ( $ step) ;
200+ $ formattedSteps [] = $ step ;
204201 }
205202 }
206203
207- // Reset storage with new formatted nested steps
208- $ this ->getLifecycle ()->getStepStorage ()->clear ();
209- $ this ->getLifecycle ()->getStepStorage ()->put ($ formattedStep );
204+ // No public function for setting the step's steps
205+ call_user_func (\Closure::bind (
206+ function () use ($ rootStep , $ formattedSteps ) {
207+ $ rootStep ->steps = $ formattedSteps ;
208+ },
209+ null ,
210+ $ rootStep
211+ ));
212+
213+ $ this ->getLifecycle ()->getStepStorage ()->put ($ rootStep );
210214
211215 $ this ->getLifecycle ()->fire (new TestCaseFinishedEvent ());
212216 }
0 commit comments