Skip to content

Commit e6f3447

Browse files
committed
MQE-317: Make rest api server host and port environment variables optional.
1 parent 17deebe commit e6f3447

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/Magento/AcceptanceTestFramework/Util/ApiClientUtil.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,31 @@ public function __construct($apiPath, $headers, $apiOperation, $jsonBody)
6868
*/
6969
public function submit($verbose = false)
7070
{
71+
$url = null;
72+
7173
if ($this->jsonBody) {
7274
curl_setopt($this->curl, CURLOPT_POSTFIELDS, $this->jsonBody);
7375
}
7476

7577
curl_setopt($this->curl, CURLOPT_VERBOSE, $verbose);
7678

79+
if ((getenv('MAGENTO_RESTAPI_SERVER_HOST') !== false)
80+
&& (getenv('MAGENTO_RESTAPI_SERVER_HOST') !== '') ) {
81+
$url = getenv('MAGENTO_RESTAPI_SERVER_HOST');
82+
} else {
83+
$url = getenv('MAGENTO_BASE_URL');
84+
}
85+
86+
if ((getenv('MAGENTO_RESTAPI_SERVER_PORT') !== false)
87+
&& (getenv('MAGENTO_RESTAPI_SERVER_PORT') !== '')) {
88+
$url .= ':' . getenv('MAGENTO_RESTAPI_SERVER_PORT');
89+
}
90+
7791
curl_setopt_array($this->curl, [
7892
CURLOPT_RETURNTRANSFER => 1,
7993
CURLOPT_HTTPHEADER => $this->headers,
8094
CURLOPT_CUSTOMREQUEST => $this->apiOperation,
81-
CURLOPT_URL => HOSTNAME . ':' . PORT . $this->apiPath
95+
CURLOPT_URL => $url . $this->apiPath
8296
]);
8397

8498
$response = curl_exec($this->curl);

0 commit comments

Comments
 (0)