Skip to content

Commit c2e9f39

Browse files
committed
MQE-70: [Test Creation] Place an Order via Guest Checkout - Via the Storefront
1 parent 17deebe commit c2e9f39

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

src/Magento/AcceptanceTestFramework/Test/Objects/ActionObject.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ActionObject
2222
const MERGE_ACTION_ORDER_AFTER = 'after';
2323
const ACTION_ATTRIBUTE_URL = 'url';
2424
const ACTION_ATTRIBUTE_SELECTOR = 'selector';
25-
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/{{[\w.]+}}/';
25+
const ACTION_ATTRIBUTE_VARIABLE_REGEX_PATTERN = '/{{[\w.\[\]]+}}/';
2626

2727
/**
2828
* The unique identifier for the action
@@ -292,8 +292,20 @@ private function findAndReplaceReferences($objectHandler, $inputString)
292292
break;
293293
case (get_class($obj) == EntityDataObject::class):
294294
list(,$objField) = $this->stripAndSplitReference($match);
295-
$replacement = $obj->getDataByName($objField);
295+
296+
if (strpos($objField, '[') == true) {
297+
// Access <array>...</array>
298+
$parts = explode('[', $objField);
299+
$name = $parts[0];
300+
$index = str_replace(']', '', $parts[1]);
301+
$replacement = $obj->getDataByName($name)[$index];
302+
} else {
303+
// Access <data></data>
304+
$replacement = $obj->getDataByName($objField);
305+
}
306+
296307
$replacement = $this->resolveEntityDataUniquenessReference($replacement, $obj, $objField);
308+
297309
break;
298310
}
299311

src/Magento/AcceptanceTestFramework/Util/ApiClientUtil.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,22 @@ public function submit($verbose = false)
8181
CURLOPT_URL => HOSTNAME . ':' . PORT . $this->apiPath
8282
]);
8383

84-
$response = curl_exec($this->curl);
84+
try {
85+
$response = curl_exec($this->curl);
86+
if ($response === false) {
87+
throw new \Exception(curl_error($this->curl), curl_errno($this->curl));
88+
}
89+
} catch (\Exception $e) {
90+
trigger_error(
91+
sprintf(
92+
'Curl failed with error #%d: %s',
93+
$e->getCode(),
94+
$e->getMessage()
95+
),
96+
E_USER_ERROR
97+
);
98+
}
99+
85100
curl_close($this->curl);
86101

87102
return $response;

0 commit comments

Comments
 (0)