Skip to content

Commit

Permalink
Merge pull request #4147 from magento-pangolin/MQE-1536-2.3
Browse files Browse the repository at this point in the history
[pangolin] MQE-1536: Magento\Install\Test\TestCase\InstallTest is failing on php 7.0
  • Loading branch information
Joan He authored May 3, 2019
2 parents a5f9488 + c6b1e10 commit 19fcb92
Show file tree
Hide file tree
Showing 20 changed files with 501 additions and 184 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
</arguments>
<waitForLoadingMaskToDisappear stepKey="waitForMaskToDisappear" after="assertSubtotal"/>
<waitForElementVisible selector="{{CheckoutCartSummarySection.shipping}}" time="60" stepKey="waitForElementToBeVisible" after="waitForMaskToDisappear"/>
<!-- Shipping can take a long time to change in builds, can't rely on an explicit wait-->
<wait time="30" stepKey="waitForShippingDetailsToLoad" after="waitForElementToBeVisible"/>
<see userInput="{{shipping}}" selector="{{CheckoutCartSummarySection.shipping}}" stepKey="assertShipping" after="waitForShippingDetailsToLoad" />
<waitForText userInput="{{shipping}}" selector="{{CheckoutCartSummarySection.shipping}}" time="60" stepKey="assertShipping" after="waitForElementToBeVisible"/>
</actionGroup>
</actionGroups>
41 changes: 30 additions & 11 deletions dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

use Magento\Mtf\Util\Protocol\CurlInterface;
use Magento\Mtf\Util\Protocol\CurlTransport;
use Magento\Mtf\Util\Protocol\CurlTransport\WebapiDecorator;

/**
* Perform bin/magento commands from command line for functional tests executions.
Expand All @@ -17,7 +18,7 @@ class Cli
/**
* Url to command.php.
*/
const URL = 'dev/tests/functional/utils/command.php';
const URL = '/dev/tests/functional/utils/command.php';

/**
* Curl transport protocol.
Expand All @@ -26,12 +27,21 @@ class Cli
*/
private $transport;

/**
* Webapi handler.
*
* @var WebapiDecorator
*/
private $webapiHandler;

/**
* @param CurlTransport $transport
* @param WebapiDecorator $webapiHandler
*/
public function __construct(CurlTransport $transport)
public function __construct(CurlTransport $transport, WebapiDecorator $webapiHandler)
{
$this->transport = $transport;
$this->webapiHandler = $webapiHandler;
}

/**
Expand All @@ -43,22 +53,31 @@ public function __construct(CurlTransport $transport)
*/
public function execute($command, $options = [])
{
$curl = $this->transport;
$curl->write($this->prepareUrl($command, $options), [], CurlInterface::GET);
$curl->read();
$curl->close();
$this->transport->write(
rtrim(str_replace('index.php', '', $_ENV['app_frontend_url']), '/') . self::URL,
$this->prepareParamArray($command, $options),
CurlInterface::POST,
[]
);
$this->transport->read();
$this->transport->close();
}

/**
* Prepare url.
* Prepare parameter array.
*
* @param string $command
* @param array $options [optional]
* @return string
* @return array
*/
private function prepareUrl($command, $options = [])
private function prepareParamArray($command, $options = [])
{
$command .= ' ' . implode(' ', $options);
return $_ENV['app_frontend_url'] . self::URL . '?command=' . urlencode($command);
if (!empty($options)) {
$command .= ' ' . implode(' ', $options);
}
return [
'token' => urlencode($this->webapiHandler->getWebapiToken()),
'command' => urlencode($command)
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Mtf\Util\Command\File\Export;

use Magento\Mtf\ObjectManagerInterface;
use Magento\Mtf\Util\Protocol\CurlTransport;
use Magento\Mtf\Util\Protocol\CurlInterface;
use Magento\Mtf\Util\Protocol\CurlTransport\WebapiDecorator;

/**
* File reader for Magento export files.
Expand Down Expand Up @@ -36,16 +36,29 @@ class Reader implements ReaderInterface
*/
private $transport;

/**
* Webapi handler.
*
* @var WebapiDecorator
*/
private $webapiHandler;

/**
* @param ObjectManagerInterface $objectManager
* @param CurlTransport $transport
* @param WebapiDecorator $webapiHandler
* @param string $template
*/
public function __construct(ObjectManagerInterface $objectManager, CurlTransport $transport, $template)
{
public function __construct(
ObjectManagerInterface $objectManager,
CurlTransport $transport,
WebapiDecorator $webapiHandler,
$template
) {
$this->objectManager = $objectManager;
$this->template = $template;
$this->transport = $transport;
$this->webapiHandler = $webapiHandler;
}

/**
Expand All @@ -70,20 +83,28 @@ public function getData()
*/
private function getFiles()
{
$this->transport->write($this->prepareUrl(), [], CurlInterface::GET);
$this->transport->write(
rtrim(str_replace('index.php', '', $_ENV['app_frontend_url']), '/') . self::URL,
$this->prepareParamArray(),
CurlInterface::POST,
[]
);
$serializedFiles = $this->transport->read();
$this->transport->close();
// phpcs:ignore Magento2.Security.InsecureFunction
return unserialize($serializedFiles, ['allowed_classes' => false]);
return unserialize($serializedFiles);
}

/**
* Prepare url.
* Prepare parameter array.
*
* @return string
* @return array
*/
private function prepareUrl()
private function prepareParamArray()
{
return $_ENV['app_frontend_url'] . self::URL . '?template=' . urlencode($this->template);
return [
'token' => urlencode($this->webapiHandler->getWebapiToken()),
'template' => urlencode($this->template)
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ReaderInterface
/**
* Url to export.php.
*/
const URL = 'dev/tests/functional/utils/export.php';
const URL = '/dev/tests/functional/utils/export.php';

/**
* Exporting files as Data object from Magento.
Expand Down
37 changes: 27 additions & 10 deletions dev/tests/functional/lib/Magento/Mtf/Util/Command/File/Log.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Magento\Mtf\Util\Command\File;

use Magento\Mtf\Util\Protocol\CurlTransport;
use Magento\Mtf\Util\Protocol\CurlTransport\WebapiDecorator;

/**
* Get content of log file in var/log folder.
Expand All @@ -16,7 +17,7 @@ class Log
/**
* Url to log.php.
*/
const URL = 'dev/tests/functional/utils/log.php';
const URL = '/dev/tests/functional/utils/log.php';

/**
* Curl transport protocol.
Expand All @@ -25,12 +26,21 @@ class Log
*/
private $transport;

/**
* Webapi handler.
*
* @var WebapiDecorator
*/
private $webapiHandler;

/**
* @param CurlTransport $transport
* @param WebapiDecorator $webapiHandler
*/
public function __construct(CurlTransport $transport)
public function __construct(CurlTransport $transport, WebapiDecorator $webapiHandler)
{
$this->transport = $transport;
$this->webapiHandler = $webapiHandler;
}

/**
Expand All @@ -41,22 +51,29 @@ public function __construct(CurlTransport $transport)
*/
public function getFileContent($name)
{
$curl = $this->transport;
$curl->write($this->prepareUrl($name), [], CurlTransport::GET);
$data = $curl->read();
$curl->close();
$this->transport->write(
rtrim(str_replace('index.php', '', $_ENV['app_frontend_url']), '/') . self::URL,
$this->prepareParamArray($name),
CurlInterface::POST,
[]
);
$data = $this->transport->read();
$this->transport->close();
// phpcs:ignore Magento2.Security.InsecureFunction
return unserialize($data);
}

/**
* Prepare url.
* Prepare parameter array.
*
* @param string $name
* @return string
* @return array
*/
private function prepareUrl($name)
private function prepareParamArray($name)
{
return $_ENV['app_frontend_url'] . self::URL . '?name=' . urlencode($name);
return [
'token' => urlencode($this->webapiHandler->getWebapiToken()),
'name' => urlencode($name)
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

use Magento\Mtf\Util\Protocol\CurlInterface;
use Magento\Mtf\Util\Protocol\CurlTransport;
use Magento\Mtf\Util\Protocol\CurlTransport\WebapiDecorator;

/**
* GeneratedCode removes generated code of Magento (like generated/code and generated/metadata).
Expand All @@ -16,7 +17,7 @@ class GeneratedCode
/**
* Url to deleteMagentoGeneratedCode.php.
*/
const URL = 'dev/tests/functional/utils/deleteMagentoGeneratedCode.php';
const URL = '/dev/tests/functional/utils/deleteMagentoGeneratedCode.php';

/**
* Curl transport protocol.
Expand All @@ -25,12 +26,21 @@ class GeneratedCode
*/
private $transport;

/**
* Webapi handler.
*
* @var WebapiDecorator
*/
private $webapiHandler;

/**
* @param CurlTransport $transport
* @param WebapiDecorator $webapiHandler
*/
public function __construct(CurlTransport $transport)
public function __construct(CurlTransport $transport, WebapiDecorator $webapiHandler)
{
$this->transport = $transport;
$this->webapiHandler = $webapiHandler;
}

/**
Expand All @@ -40,10 +50,25 @@ public function __construct(CurlTransport $transport)
*/
public function delete()
{
$url = $_ENV['app_frontend_url'] . self::URL;
$curl = $this->transport;
$curl->write($url, [], CurlInterface::GET);
$curl->read();
$curl->close();
$this->transport->write(
rtrim(str_replace('index.php', '', $_ENV['app_frontend_url']), '/') . self::URL,
$this->prepareParamArray(),
CurlInterface::POST,
[]
);
$this->transport->read();
$this->transport->close();
}

/**
* Prepare parameter array.
*
* @return array
*/
private function prepareParamArray()
{
return [
'token' => urlencode($this->webapiHandler->getWebapiToken())
];
}
}
Loading

0 comments on commit 19fcb92

Please sign in to comment.