diff --git a/composer.json b/composer.json index 5a5f6d7c2..e0a3f52bb 100755 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "php": "7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2.0", "allure-framework/allure-codeception": "~1.3.0", "ext-curl": "*", - "codeception/codeception": "~2.3.4", + "codeception/codeception": "~2.3.4 || ~2.4.0 ", "consolidation/robo": "^1.0.0", "epfremme/swagger-php": "^2.0", "flow/jsonpath": ">0.2", diff --git a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php index 4b77909a9..184a5eacf 100644 --- a/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php +++ b/src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php @@ -16,6 +16,7 @@ class TestContextExtension extends BaseExtension { const TEST_PHASE_AFTER = "_after"; + const CODECEPT_AFTER_VERSION = "2.3.9"; const TEST_FAILED_FILE = 'failed'; /** @@ -69,7 +70,7 @@ public function testFail(\Codeception\Event\FailEvent $e) $this->runAfterBlock($e, $cest); } } - + /** * Codeception event listener function, triggered on test ending (naturally or by error). * @param \Codeception\Event\TestEvent $e @@ -117,13 +118,15 @@ private function runAfterBlock($e, $cest) try { $actorClass = $e->getTest()->getMetadata()->getCurrent('actor'); $I = new $actorClass($cest->getScenario()); - call_user_func(\Closure::bind( - function () use ($cest, $I) { - $cest->executeHook($I, 'after'); - }, - null, - $cest - )); + if (version_compare(Codeception\Codecept::VERSION, TestContextExtension::CODECEPT_AFTER_VERSION, "<=")) { + call_user_func(\Closure::bind( + function () use ($cest, $I) { + $cest->executeHook($I, 'after'); + }, + null, + $cest + )); + } } catch (\Exception $e) { // Do not rethrow Exception }