Skip to content

Commit 6de0682

Browse files
DavertMikbaev
authored andcommitted
add support for codeception 3 (via #47)
1 parent aec3db1 commit 6de0682

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"require": {
1919
"php": ">=5.4.0",
20-
"codeception/codeception": "~2.1",
20+
"codeception/codeception": "^2.3|^3.0",
2121
"allure-framework/allure-php-api": "~1.1.0",
2222
"symfony/filesystem": ">=2.6",
2323
"symfony/finder": ">=2.6"

src/Yandex/Allure/Codeception/AllureCodeception.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
22
namespace Yandex\Allure\Codeception;
33

4+
use Codeception\Codecept;
45
use Codeception\Configuration;
6+
use Codeception\Extension;
57
use Codeception\Event\FailEvent;
68
use Codeception\Event\StepEvent;
79
use Codeception\Event\SuiteEvent;
810
use Codeception\Event\TestEvent;
911
use Codeception\Events;
1012
use Codeception\Exception\ConfigurationException;
11-
use Codeception\Platform\Extension;
1213
use Codeception\Test\Cept;
1314
use Codeception\Test\Cest;
1415
use Codeception\Test\Gherkin;
@@ -35,6 +36,7 @@
3536
use Yandex\Allure\Adapter\Event\TestSuiteFinishedEvent;
3637
use Yandex\Allure\Adapter\Event\TestSuiteStartedEvent;
3738
use Yandex\Allure\Adapter\Model;
39+
use Yandex\Allure\Adapter\Model\Attachment;
3840
use Yandex\Allure\Adapter\Model\Label;
3941
use Yandex\Allure\Adapter\Model\LabelType;
4042
use Yandex\Allure\Adapter\Model\ParameterKind;
@@ -286,7 +288,7 @@ function ($a) {
286288
$annotationManager = new Annotation\AnnotationManager($annotations);
287289
$annotationManager->updateTestCaseEvent($event);
288290
}
289-
} else if ($test instanceof \PHPUnit_Framework_TestCase) {
291+
} else if ($test instanceof \PHPUnit\Framework\TestCase) {
290292
$methodName = $this->methodName = $test->getName(false);
291293
$className = get_class($test);
292294
if (class_exists($className, false)) {
@@ -377,8 +379,16 @@ public function testSkipped(FailEvent $failEvent)
377379
$this->getLifecycle()->fire($event->withException($e)->withMessage($message));
378380
}
379381

380-
public function testEnd()
382+
public function testEnd(TestEvent $testEvent)
381383
{
384+
// attachments supported since Codeception 3.0
385+
if (version_compare(Codecept::VERSION, '3.0.0') > -1) {
386+
$artifacts = $testEvent->getTest()->getMetadata()->getReports();
387+
$testCaseStorage = $this->getLifecycle()->getTestCaseStorage()->get();
388+
foreach ($artifacts as $name => $artifact) {
389+
$testCaseStorage->addAttachment(new Attachment($name, $artifact, null));
390+
}
391+
}
382392
$this->getLifecycle()->fire(new TestCaseFinishedEvent());
383393
}
384394

0 commit comments

Comments
 (0)