Skip to content

Commit a304e8e

Browse files
authored
Merge pull request magento#250 from magento/MQE-910-develop
MQE-910: [GitHub] The property of the parent element is used first when making a request
2 parents 070dbeb + def54b2 commit a304e8e

File tree

1 file changed

+22
-4
lines changed
  • src/Magento/FunctionalTestingFramework/DataGenerator/Persist

1 file changed

+22
-4
lines changed

src/Magento/FunctionalTestingFramework/DataGenerator/Persist/CurlHandler.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,33 @@ private function resolveUrlReference($urlIn, $entityObjects)
197197
{
198198
$urlOut = $urlIn;
199199
$matchedParams = [];
200+
// Find all the params ({}) references
200201
preg_match_all("/[{](.+?)[}]/", $urlIn, $matchedParams);
201202

202203
if (!empty($matchedParams)) {
203204
foreach ($matchedParams[0] as $paramKey => $paramValue) {
205+
$paramEntityParent = "";
206+
$matchedParent = [];
207+
$dataItem = $matchedParams[1][$paramKey];
208+
// Find all the parent property (Type.key) references, assuming there will be only one
209+
// parent property reference within one param
210+
preg_match_all("/(.+?)\./", $dataItem, $matchedParent);
211+
212+
if (!empty($matchedParent) && !empty($matchedParent[0])) {
213+
$paramEntityParent = $matchedParent[1][0];
214+
$dataItem = preg_replace('/^'.$matchedParent[0][0].'/', '', $dataItem);
215+
}
216+
204217
foreach ($entityObjects as $entityObject) {
205-
$param = $entityObject->getDataByName(
206-
$matchedParams[1][$paramKey],
207-
EntityDataObject::CEST_UNIQUE_VALUE
208-
);
218+
$param = null;
219+
220+
if ($paramEntityParent === "" || $entityObject->getType() == $paramEntityParent) {
221+
$param = $entityObject->getDataByName(
222+
$dataItem,
223+
EntityDataObject::CEST_UNIQUE_VALUE
224+
);
225+
}
226+
209227
if (null !== $param) {
210228
$urlOut = str_replace($paramValue, $param, $urlOut);
211229
continue;

0 commit comments

Comments
 (0)