Skip to content

Commit 05af991

Browse files
committed
MQE-391: Variable is not correctly resolved when array symbol ([ or ]) is inside $$ signs
- Reverted most changes and just kept regex change to accomodate [].
1 parent a92df01 commit 05af991

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

src/Magento/FunctionalTestingFramework/Util/TestGenerator.php

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -816,19 +816,7 @@ private function resolveTestVariable($inputString, $quoteBreak = false)
816816
". Hook persisted entity references must follow \$\$entityMergeKey.field\$\$ format."
817817
);
818818
}
819-
preg_match_all("/\[[\w.]+\]/", $variable[1], $arrayMatch);
820-
if (!empty($arrayMatch[0])) {
821-
$variable[1] = str_replace($arrayMatch[0][0], "", $variable[1]);
822-
$arrayMatch[0][0] = trim($arrayMatch[0][0], "[]");
823-
$replacement = sprintf(
824-
"\$this->%s->getCreatedDataByName('%s')['%s']",
825-
$variable[0],
826-
$variable[1],
827-
$arrayMatch[0][0]
828-
);
829-
} else {
830-
$replacement = sprintf("\$this->%s->getCreatedDataByName('%s')", $variable[0], $variable[1]);
831-
}
819+
$replacement = sprintf("\$this->%s->getCreatedDataByName('%s')", $variable[0], $variable[1]);
832820
if ($quoteBreak) {
833821
$replacement = '" . ' . $replacement . ' . "';
834822
}
@@ -847,19 +835,7 @@ private function resolveTestVariable($inputString, $quoteBreak = false)
847835
". Test persisted entity references must follow \$entityMergeKey.field\$ format."
848836
);
849837
}
850-
preg_match_all("/\[[\w.]+\]/", $variable[1], $arrayMatch);
851-
if (!empty($arrayMatch[0])) {
852-
$variable[1] = str_replace($arrayMatch[0][0], "", $variable[1]);
853-
$arrayMatch[0][0] = trim($arrayMatch[0][0], "[]");
854-
$replacement = sprintf(
855-
"$%s->getCreatedDataByName('%s')['%s']",
856-
$variable[0],
857-
$variable[1],
858-
$arrayMatch[0][0]
859-
);
860-
} else {
861-
$replacement = sprintf("$%s->getCreatedDataByName('%s')", $variable[0], $variable[1]);
862-
}
838+
$replacement = sprintf("$%s->getCreatedDataByName('%s')", $variable[0], $variable[1]);
863839
if ($quoteBreak) {
864840
$replacement = '" . ' . $replacement . ' . "';
865841
}

0 commit comments

Comments
 (0)