-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathAllureHelper.php
46 lines (41 loc) · 1.38 KB
/
AllureHelper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\FunctionalTestingFramework\Allure;
use Magento\FunctionalTestingFramework\Allure\Event\AddUniqueAttachmentEvent;
use Yandex\Allure\Adapter\Allure;
use Yandex\Allure\Adapter\Event\AddAttachmentEvent;
class AllureHelper
{
/**
* Adds attachment to the current step
* @param mixed $data
* @param string $caption
* @throws \Yandex\Allure\Adapter\AllureException
* @return void
*/
public static function addAttachmentToCurrentStep($data, $caption)
{
Allure::lifecycle()->fire(new AddUniqueAttachmentEvent($data, $caption));
}
/**
* Adds Attachment to the last executed step.
* Use this when adding attachments outside of an $I->doSomething() step/context.
* @param mixed $data
* @param string $caption
* @return void
*/
public static function addAttachmentToLastStep($data, $caption)
{
$rootStep = Allure::lifecycle()->getStepStorage()->getLast();
$trueLastStep = array_last($rootStep->getSteps());
if ($trueLastStep == null) {
// Nothing to attach to; do not fire off allure event
return;
}
$attachmentEvent = new AddUniqueAttachmentEvent($data, $caption);
$attachmentEvent->process($trueLastStep);
}
}