9
9
use Magento \FunctionalTestingFramework \Suite \Handlers \SuiteObjectHandler ;
10
10
use Magento \FunctionalTestingFramework \Test \Objects \ActionGroupObject ;
11
11
use \Magento \FunctionalTestingFramework \Util \TestGenerator ;
12
+ use Yandex \Allure \Adapter \Model \Status ;
12
13
use Yandex \Allure \Adapter \Model \Step ;
13
14
use Yandex \Allure \Codeception \AllureCodeception ;
14
15
use Yandex \Allure \Adapter \Event \StepStartedEvent ;
15
16
use Yandex \Allure \Adapter \Event \StepFinishedEvent ;
16
17
use Yandex \Allure \Adapter \Event \StepFailedEvent ;
17
18
use Yandex \Allure \Adapter \Event \TestCaseFailedEvent ;
18
19
use Yandex \Allure \Adapter \Event \TestCaseFinishedEvent ;
20
+ use Yandex \Allure \Adapter \Event \TestCaseBrokenEvent ;
19
21
use Codeception \Event \FailEvent ;
20
22
use Codeception \Event \SuiteEvent ;
21
23
use Codeception \Event \StepEvent ;
@@ -187,10 +189,37 @@ public function testIncomplete(FailEvent $failEvent)
187
189
$ this ->getLifecycle ()->fire ($ event ->withException ($ e )->withMessage ($ message ));
188
190
}
189
191
192
+ /**
193
+ * Override of parent method. Adds in steps for hard PHP Errors if they arrise.
194
+ *
195
+ * @param FailEvent $failEvent
196
+ * @return void
197
+ */
198
+ public function testError (FailEvent $ failEvent )
199
+ {
200
+ $ event = new TestCaseBrokenEvent ();
201
+ $ e = $ failEvent ->getFail ();
202
+ $ message = $ e ->getMessage ();
203
+
204
+ // Create new step with an error for Allure
205
+ $ failStep = new Step ();
206
+ $ failStep ->setName ("ERROR " );
207
+ $ failStep ->setTitle ($ message );
208
+ $ failStep ->setStatus (Status::BROKEN );
209
+
210
+ // Retrieve Allure Steps and add in the new BROKEN step
211
+ $ rootStep = $ this ->getLifecycle ()->getStepStorage ()->pollLast ();
212
+ $ rootStep ->addStep ($ failStep );
213
+ $ this ->getLifecycle ()->getStepStorage ()->put ($ rootStep );
214
+
215
+ $ this ->getLifecycle ()->fire ($ event ->withException ($ e )->withMessage ($ message ));
216
+ }
217
+
190
218
/**
191
219
* Override of parent method, polls stepStorage for testcase and formats it according to actionGroup nesting.
192
220
*
193
221
* @return void
222
+ * @SuppressWarnings(PHPMD)
194
223
*/
195
224
public function testEnd ()
196
225
{
@@ -207,6 +236,13 @@ public function testEnd()
207
236
}
208
237
// if actionGroup flag, start nesting
209
238
if (strpos ($ step ->getName (), ActionGroupObject::ACTION_GROUP_CONTEXT_START ) !== false ) {
239
+ if ($ actionGroupStepContainer !== null ) {
240
+ //actionGroup still being nested, need to close out and finish it.
241
+ $ formattedSteps [] = $ actionGroupStepContainer ;
242
+ $ actionGroupStepContainer = null ;
243
+ $ actionGroupStepKey = null ;
244
+ }
245
+
210
246
$ step ->setName (str_replace (ActionGroupObject::ACTION_GROUP_CONTEXT_START , '' , $ step ->getName ()));
211
247
$ actionGroupStepContainer = $ step ;
212
248
0 commit comments