Skip to content

Commit

Permalink
MQE-1152: Remove redundant after execution for codeception 2.4.4 and …
Browse files Browse the repository at this point in the history
…update composer.json

- Added Conditional for checking Codeception Version
  • Loading branch information
aljcalandra authored and KevinBKozan committed Jan 22, 2019
1 parent 680d9b9 commit c80e1d3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit c80e1d3

Please sign in to comment.