Skip to content

Commit c80e1d3

Browse files
aljcalandraKevinBKozan
authored andcommitted
MQE-1152: Remove redundant after execution for codeception 2.4.4 and update composer.json
- Added Conditional for checking Codeception Version
1 parent 680d9b9 commit c80e1d3

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"php": "7.0.2|7.0.4|~7.0.6|~7.1.0|~7.2.0",
1313
"allure-framework/allure-codeception": "~1.3.0",
1414
"ext-curl": "*",
15-
"codeception/codeception": "~2.3.4",
15+
"codeception/codeception": "~2.3.4 || ~2.4.0 ",
1616
"consolidation/robo": "^1.0.0",
1717
"epfremme/swagger-php": "^2.0",
1818
"flow/jsonpath": ">0.2",

src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
class TestContextExtension extends BaseExtension
1717
{
1818
const TEST_PHASE_AFTER = "_after";
19+
const CODECEPT_AFTER_VERSION = "2.3.9";
1920
const TEST_FAILED_FILE = 'failed';
2021

2122
/**
@@ -69,7 +70,7 @@ public function testFail(\Codeception\Event\FailEvent $e)
6970
$this->runAfterBlock($e, $cest);
7071
}
7172
}
72-
73+
7374
/**
7475
* Codeception event listener function, triggered on test ending (naturally or by error).
7576
* @param \Codeception\Event\TestEvent $e
@@ -117,13 +118,15 @@ private function runAfterBlock($e, $cest)
117118
try {
118119
$actorClass = $e->getTest()->getMetadata()->getCurrent('actor');
119120
$I = new $actorClass($cest->getScenario());
120-
call_user_func(\Closure::bind(
121-
function () use ($cest, $I) {
122-
$cest->executeHook($I, 'after');
123-
},
124-
null,
125-
$cest
126-
));
121+
if (version_compare(Codeception\Codecept::VERSION, TestContextExtension::CODECEPT_AFTER_VERSION, "<=")) {
122+
call_user_func(\Closure::bind(
123+
function () use ($cest, $I) {
124+
$cest->executeHook($I, 'after');
125+
},
126+
null,
127+
$cest
128+
));
129+
}
127130
} catch (\Exception $e) {
128131
// Do not rethrow Exception
129132
}

0 commit comments

Comments
 (0)