|
1 | 1 | <?php |
2 | 2 | namespace Yandex\Allure\Codeception; |
3 | 3 |
|
| 4 | +use Codeception\Codecept; |
4 | 5 | use Codeception\Configuration; |
| 6 | +use Codeception\Extension; |
5 | 7 | use Codeception\Event\FailEvent; |
6 | 8 | use Codeception\Event\StepEvent; |
7 | 9 | use Codeception\Event\SuiteEvent; |
8 | 10 | use Codeception\Event\TestEvent; |
9 | 11 | use Codeception\Events; |
10 | 12 | use Codeception\Exception\ConfigurationException; |
11 | | -use Codeception\Platform\Extension; |
12 | 13 | use Codeception\Test\Cept; |
13 | 14 | use Codeception\Test\Cest; |
14 | 15 | use Codeception\Test\Gherkin; |
|
35 | 36 | use Yandex\Allure\Adapter\Event\TestSuiteFinishedEvent; |
36 | 37 | use Yandex\Allure\Adapter\Event\TestSuiteStartedEvent; |
37 | 38 | use Yandex\Allure\Adapter\Model; |
| 39 | +use Yandex\Allure\Adapter\Model\Attachment; |
38 | 40 | use Yandex\Allure\Adapter\Model\Label; |
39 | 41 | use Yandex\Allure\Adapter\Model\LabelType; |
40 | 42 | use Yandex\Allure\Adapter\Model\ParameterKind; |
@@ -286,7 +288,7 @@ function ($a) { |
286 | 288 | $annotationManager = new Annotation\AnnotationManager($annotations); |
287 | 289 | $annotationManager->updateTestCaseEvent($event); |
288 | 290 | } |
289 | | - } else if ($test instanceof \PHPUnit_Framework_TestCase) { |
| 291 | + } else if ($test instanceof \PHPUnit\Framework\TestCase) { |
290 | 292 | $methodName = $this->methodName = $test->getName(false); |
291 | 293 | $className = get_class($test); |
292 | 294 | if (class_exists($className, false)) { |
@@ -377,8 +379,16 @@ public function testSkipped(FailEvent $failEvent) |
377 | 379 | $this->getLifecycle()->fire($event->withException($e)->withMessage($message)); |
378 | 380 | } |
379 | 381 |
|
380 | | - public function testEnd() |
| 382 | + public function testEnd(TestEvent $testEvent) |
381 | 383 | { |
| 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 | + } |
382 | 392 | $this->getLifecycle()->fire(new TestCaseFinishedEvent()); |
383 | 393 | } |
384 | 394 |
|
|
0 commit comments