Skip to content

Commit 0a6db18

Browse files
committed
MQE-2575: Allow MFTF Helpers to Return Data to MFTF Test
1 parent da431d6 commit 0a6db18

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,12 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato
898898
$stepKey,
899899
$customActionAttributes['class'] . '::' . $customActionAttributes['method']
900900
);
901-
$testSteps .= $this->wrapFunctionCall($actor, $actionObject, $arguments);
901+
$testSteps .= $this->wrapFunctionCallWithReturnValue(
902+
$stepKey,
903+
$actor,
904+
$actionObject,
905+
$arguments
906+
);
902907
break;
903908
case "createData":
904909
$entity = $customActionAttributes['entity'];
@@ -2016,16 +2021,7 @@ private function addDollarSign($input)
20162021
*/
20172022
private function wrapFunctionCall($actor, $action, ...$args)
20182023
{
2019-
$isFirst = true;
2020-
$isActionHelper = $action->getType() === 'helper';
2021-
$actionType = $action->getType();
2022-
if ($isActionHelper) {
2023-
$actor = "this->helperContainer->get('" . $action->getCustomActionAttributes()['class'] . "')";
2024-
$args = $args[0];
2025-
$actionType = $action->getCustomActionAttributes()['method'];
2026-
}
2027-
2028-
$output = sprintf("\t\t$%s->%s(", $actor, $actionType);
2024+
$output = sprintf("\t\t$%s->%s(", $actor, $action->getType());
20292025
for ($i = 0; $i < count($args); $i++) {
20302026
if (null === $args[$i]) {
20312027
continue;
@@ -2055,8 +2051,13 @@ private function wrapFunctionCall($actor, $action, ...$args)
20552051
*/
20562052
private function wrapFunctionCallWithReturnValue($returnVariable, $actor, $action, ...$args)
20572053
{
2058-
$isFirst = true;
2059-
$output = sprintf("\t\t$%s = $%s->%s(", $returnVariable, $actor, $action->getType());
2054+
$actionType = $action->getType();
2055+
if ($actionType === 'helper') {
2056+
$actor = "this->helperContainer->get('" . $action->getCustomActionAttributes()['class'] . "')";
2057+
$args = $args[0];
2058+
$actionType = $action->getCustomActionAttributes()['method'];
2059+
}
2060+
$output = sprintf("\t\t$%s = $%s->%s(", $returnVariable, $actor, $actionType);
20602061
for ($i = 0; $i < count($args); $i++) {
20612062
if (null === $args[$i]) {
20622063
continue;

0 commit comments

Comments
 (0)