Skip to content

Commit 8c80ca8

Browse files
authored
Merge pull request #213 from magento/MQE-1168
MQE-1168: magentoCLI action not working properly if URL to magento co…
2 parents 652b599 + 268c9ff commit 8c80ca8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\FunctionalTestingFramework\Util\Protocol\CurlInterface;
2020
use Magento\FunctionalTestingFramework\Util\ConfigSanitizerUtil;
2121
use Yandex\Allure\Adapter\Support\AttachmentSupport;
22+
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
2223

2324
/**
2425
* MagentoWebDriver module provides common Magento web actions through Selenium WebDriver.
@@ -319,6 +320,7 @@ public function searchAndMultiSelectOption($select, array $options, $requireActi
319320
* @param string $selectSearchTextField
320321
* @param string $selectSearchResult
321322
* @param string[] $options
323+
* @throws \Exception
322324
* @return void
323325
*/
324326
public function selectMultipleOptions($selectSearchTextField, $selectSearchResult, array $options)
@@ -474,14 +476,17 @@ public function scrollToTopOfPage()
474476
* Takes given $command and executes it against exposed MTF CLI entry point. Returns response from server.
475477
* @param string $command
476478
* @param string $arguments
479+
* @throws TestFrameworkException
477480
* @return string
478481
*/
479482
public function magentoCLI($command, $arguments = null)
480483
{
481-
// trim everything after first '/' in URL after (ex http://magento.instance/<index.php>)
482-
preg_match("/.+\/\/[^\/]+\/?/", $this->config['url'], $trimmed);
483-
$trimmedUrl = $trimmed[0];
484-
$apiURL = $trimmedUrl . ltrim(getenv('MAGENTO_CLI_COMMAND_PATH'), '/');
484+
// Remove index.php if it's present in url
485+
$baseUrl = rtrim(
486+
str_replace('index.php', '', rtrim($this->config['url'], '/')),
487+
'/'
488+
);
489+
$apiURL = $baseUrl . '/' . ltrim(getenv('MAGENTO_CLI_COMMAND_PATH'), '/');
485490

486491
$executor = new CurlTransport();
487492
$executor->write(
@@ -501,6 +506,7 @@ public function magentoCLI($command, $arguments = null)
501506
/**
502507
* Runs DELETE request to delete a Magento entity against the url given.
503508
* @param string $url
509+
* @throws TestFrameworkException
504510
* @return string
505511
*/
506512
public function deleteEntityByUrl($url)

0 commit comments

Comments
 (0)