From c7f3f5c8ba3a6e139deca497eac99f8c8943d107 Mon Sep 17 00:00:00 2001 From: Michael Bodnarchuk Date: Tue, 18 Jun 2019 21:23:09 +0300 Subject: [PATCH 1/5] Support Codeception 3.0 Support latest Codeception --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0bb554c..92d9beb 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require": { "php": ">=5.4.0", - "codeception/codeception": "~2.1", + "codeception/codeception": "^2.1|^3.0", "allure-framework/allure-php-api": "~1.1.0", "symfony/filesystem": ">=2.6", "symfony/finder": ">=2.6" From 2f45ca6976bd5334163192d87cb659ba415eca59 Mon Sep 17 00:00:00 2001 From: Michael Bodnarchuk Date: Tue, 18 Jun 2019 22:27:31 +0300 Subject: [PATCH 2/5] Added artifacts / attachments support, updated PHPUnit naming --- src/Yandex/Allure/Codeception/AllureCodeception.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Yandex/Allure/Codeception/AllureCodeception.php b/src/Yandex/Allure/Codeception/AllureCodeception.php index 35dfb6a..a98d7be 100644 --- a/src/Yandex/Allure/Codeception/AllureCodeception.php +++ b/src/Yandex/Allure/Codeception/AllureCodeception.php @@ -2,13 +2,13 @@ namespace Yandex\Allure\Codeception; use Codeception\Configuration; +use Codeception\Extension; use Codeception\Event\FailEvent; use Codeception\Event\StepEvent; use Codeception\Event\SuiteEvent; use Codeception\Event\TestEvent; use Codeception\Events; use Codeception\Exception\ConfigurationException; -use Codeception\Platform\Extension; use Codeception\Test\Cept; use Codeception\Test\Cest; use Codeception\Test\Gherkin; @@ -286,7 +286,7 @@ function ($a) { $annotationManager = new Annotation\AnnotationManager($annotations); $annotationManager->updateTestCaseEvent($event); } - } else if ($test instanceof \PHPUnit_Framework_TestCase) { + } else if ($test instanceof \PHPUnit\Framework\TestCase) { $methodName = $this->methodName = $test->getName(false); $className = get_class($test); if (class_exists($className, false)) { @@ -377,8 +377,15 @@ public function testSkipped(FailEvent $failEvent) $this->getLifecycle()->fire($event->withException($e)->withMessage($message)); } - public function testEnd() + public function testEnd(TestEvent $testEvent) { + $artifacts = $testEvent->getTest()->getMetadata()->getReports(); + if (!empty($artifacts)) { + $testCaseStorage = $this->getLifecycle()->getTestCaseStorage()->get(); + foreach ($artifacts as $name => $artifact) { + $testCaseStorage->addAttachment(new Model\Attachment($name, $artifact, null)); + } + } $this->getLifecycle()->fire(new TestCaseFinishedEvent()); } From a0c116da942f6ab6c964f9bc33ea76c045ce5022 Mon Sep 17 00:00:00 2001 From: Michael Bodnarchuk Date: Tue, 18 Jun 2019 22:32:16 +0300 Subject: [PATCH 3/5] Update AllureCodeception.php --- src/Yandex/Allure/Codeception/AllureCodeception.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Yandex/Allure/Codeception/AllureCodeception.php b/src/Yandex/Allure/Codeception/AllureCodeception.php index a98d7be..d8269f2 100644 --- a/src/Yandex/Allure/Codeception/AllureCodeception.php +++ b/src/Yandex/Allure/Codeception/AllureCodeception.php @@ -1,6 +1,7 @@ getTest()->getMetadata()->getReports(); - if (!empty($artifacts)) { + // attachments supported since Codeception 3.0 + if (version_compare(Codecept::VERSION, '3.0.0') > -1) { + $artifacts = $testEvent->getTest()->getMetadata()->getReports(); $testCaseStorage = $this->getLifecycle()->getTestCaseStorage()->get(); foreach ($artifacts as $name => $artifact) { $testCaseStorage->addAttachment(new Model\Attachment($name, $artifact, null)); From ffa280516ad96f7d7b28b9b0d3a069674eba8220 Mon Sep 17 00:00:00 2001 From: Michael Bodnarchuk Date: Tue, 18 Jun 2019 22:32:43 +0300 Subject: [PATCH 4/5] Ensure version compatibility --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 92d9beb..d4ef8bb 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require": { "php": ">=5.4.0", - "codeception/codeception": "^2.1|^3.0", + "codeception/codeception": "^2.3|^3.0", "allure-framework/allure-php-api": "~1.1.0", "symfony/filesystem": ">=2.6", "symfony/finder": ">=2.6" From fabf1a41e65a5a2bf5151faf7baa30bf1c4ad14f Mon Sep 17 00:00:00 2001 From: Michael Bodnarchuk Date: Tue, 18 Jun 2019 22:34:16 +0300 Subject: [PATCH 5/5] Used FQN for Attachment class --- src/Yandex/Allure/Codeception/AllureCodeception.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Yandex/Allure/Codeception/AllureCodeception.php b/src/Yandex/Allure/Codeception/AllureCodeception.php index d8269f2..51a23a2 100644 --- a/src/Yandex/Allure/Codeception/AllureCodeception.php +++ b/src/Yandex/Allure/Codeception/AllureCodeception.php @@ -36,6 +36,7 @@ use Yandex\Allure\Adapter\Event\TestSuiteFinishedEvent; use Yandex\Allure\Adapter\Event\TestSuiteStartedEvent; use Yandex\Allure\Adapter\Model; +use Yandex\Allure\Adapter\Model\Attachment; use Yandex\Allure\Adapter\Model\Label; use Yandex\Allure\Adapter\Model\LabelType; use Yandex\Allure\Adapter\Model\ParameterKind; @@ -385,7 +386,7 @@ public function testEnd(TestEvent $testEvent) $artifacts = $testEvent->getTest()->getMetadata()->getReports(); $testCaseStorage = $this->getLifecycle()->getTestCaseStorage()->get(); foreach ($artifacts as $name => $artifact) { - $testCaseStorage->addAttachment(new Model\Attachment($name, $artifact, null)); + $testCaseStorage->addAttachment(new Attachment($name, $artifact, null)); } } $this->getLifecycle()->fire(new TestCaseFinishedEvent());