@@ -168,12 +168,9 @@ public function testIncomplete(FailEvent $failEvent)
168
168
*/
169
169
public function testEnd ()
170
170
{
171
+ // Pops top of stepStorage, need to add it back in after processing
171
172
$ 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 = [];
177
174
$ actionGroupStepContainer = null ;
178
175
179
176
foreach ($ rootStep ->getSteps () as $ step ) {
@@ -185,7 +182,7 @@ public function testEnd()
185
182
}
186
183
// if actionGroup ended, add stack to steps
187
184
if (stripos ($ step ->getName (), ActionGroupObject::ACTION_GROUP_CONTEXT_END ) !== false ) {
188
- $ formattedStep -> addStep ( $ actionGroupStepContainer) ;
185
+ $ formattedSteps [] = $ actionGroupStepContainer ;
189
186
$ actionGroupStepContainer = null ;
190
187
continue ;
191
188
}
@@ -195,18 +192,25 @@ public function testEnd()
195
192
if ($ step ->getStatus () !== self ::STEP_PASSED ) {
196
193
// If step didn't pass, need to end action group nesting and set overall step status
197
194
$ actionGroupStepContainer ->setStatus ($ step ->getStatus ());
198
- $ formattedStep -> addStep ( $ actionGroupStepContainer) ;
195
+ $ formattedSteps [] = $ actionGroupStepContainer ;
199
196
$ actionGroupStepContainer = null ;
200
197
}
201
198
} else {
202
199
// Add step as normal
203
- $ formattedStep -> addStep ( $ step) ;
200
+ $ formattedSteps [] = $ step ;
204
201
}
205
202
}
206
203
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 );
210
214
211
215
$ this ->getLifecycle ()->fire (new TestCaseFinishedEvent ());
212
216
}
0 commit comments