Skip to content

Commit 468b62b

Browse files
committed
MQE-1704: MFTF Compatibility with PHPUnit 8
Fixed phpmd error
1 parent 44ba26b commit 468b62b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/Magento/FunctionalTestingFramework/Allure/Adapter/MagentoAllureAdapter.php

+15-6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Magento\FunctionalTestingFramework\Util\TestGenerator;
1515
use Yandex\Allure\Adapter\Model\Status;
1616
use Yandex\Allure\Adapter\Model\Step;
17+
use Yandex\Allure\Adapter\Allure;
1718
use Yandex\Allure\Codeception\AllureCodeception;
1819
use Yandex\Allure\Adapter\Event\StepStartedEvent;
1920
use Yandex\Allure\Adapter\Event\StepFinishedEvent;
@@ -82,7 +83,7 @@ public function suiteBefore(SuiteEvent $suiteEvent)
8283

8384
call_user_func(\Closure::bind(
8485
function () use ($suite, $suiteName) {
85-
$suite->name = $suiteName;
86+
$suite->setName($suiteName);
8687
},
8788
null,
8889
$suite
@@ -249,11 +250,8 @@ public function testError(FailEvent $failEvent)
249250

250251
/**
251252
* Override of parent method, polls stepStorage for testcase and formats it according to actionGroup nesting.
252-
*
253253
* @param TestEvent $testEvent
254-
*
255254
* @throws \Yandex\Allure\Adapter\AllureException
256-
*
257255
* @return void
258256
*/
259257
public function testEnd(TestEvent $testEvent)
@@ -317,15 +315,26 @@ function () use ($rootStep, $formattedSteps) {
317315

318316
$this->getLifecycle()->getStepStorage()->put($rootStep);
319317

318+
$this->addAttachmentEvent($testEvent);
319+
320+
$this->getLifecycle()->fire(new TestCaseFinishedEvent());
321+
}
322+
323+
/**
324+
* Fire add attachment event
325+
* @param TestEvent $testEvent
326+
* @throws \Yandex\Allure\Adapter\AllureException
327+
* @return void
328+
*/
329+
private function addAttachmentEvent(TestEvent $testEvent)
330+
{
320331
// attachments supported since Codeception 3.0
321332
if (version_compare(Codecept::VERSION, '3.0.0') > -1 && $testEvent->getTest() instanceof Cest) {
322333
$artifacts = $testEvent->getTest()->getMetadata()->getReports();
323334
foreach ($artifacts as $name => $artifact) {
324335
Allure::lifecycle()->fire(new AddAttachmentEvent($artifact, $name, null));
325336
}
326337
}
327-
328-
$this->getLifecycle()->fire(new TestCaseFinishedEvent());
329338
}
330339

331340
/**

0 commit comments

Comments
 (0)