Skip to content

Commit

Permalink
Merge pull request #4088 from magento-trigger/MAGETWO-99210
Browse files Browse the repository at this point in the history
[trigger] MAGETWO-99210: Magento\Install\Test\TestCase\InstallTest is failing on php 7.1
  • Loading branch information
fascinosum authored Apr 22, 2019
2 parents 0ae802b + 264df42 commit 1d1c2ea
Show file tree
Hide file tree
Showing 20 changed files with 201 additions and 444 deletions.
41 changes: 11 additions & 30 deletions dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

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 @@ -18,7 +17,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 @@ -27,21 +26,12 @@ class Cli
*/
private $transport;

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

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

/**
Expand All @@ -53,31 +43,22 @@ public function __construct(CurlTransport $transport, WebapiDecorator $webapiHan
*/
public function execute($command, $options = [])
{
$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();
$curl = $this->transport;
$curl->write($this->prepareUrl($command, $options), [], CurlInterface::GET);
$curl->read();
$curl->close();
}

/**
* Prepare parameter array.
* Prepare url.
*
* @param string $command
* @param array $options [optional]
* @return array
* @return string
*/
private function prepareParamArray($command, $options = [])
private function prepareUrl($command, $options = [])
{
if (!empty($options)) {
$command .= ' ' . implode(' ', $options);
}
return [
'token' => urlencode($this->webapiHandler->getWebapiToken()),
'command' => urlencode($command)
];
$command .= ' ' . implode(' ', $options);
return $_ENV['app_frontend_url'] . self::URL . '?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,29 +36,16 @@ 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,
WebapiDecorator $webapiHandler,
$template
) {
public function __construct(ObjectManagerInterface $objectManager, CurlTransport $transport, $template)
{
$this->objectManager = $objectManager;
$this->template = $template;
$this->transport = $transport;
$this->webapiHandler = $webapiHandler;
}

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

/**
* Prepare parameter array.
* Prepare url.
*
* @return array
* @return string
*/
private function prepareParamArray()
private function prepareUrl()
{
return [
'token' => urlencode($this->webapiHandler->getWebapiToken()),
'template' => urlencode($this->template)
];
return $_ENV['app_frontend_url'] . self::URL . '?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
38 changes: 11 additions & 27 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,7 +7,6 @@
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 @@ -17,7 +16,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 @@ -26,21 +25,12 @@ class Log
*/
private $transport;

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

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

/**
Expand All @@ -51,28 +41,22 @@ public function __construct(CurlTransport $transport, WebapiDecorator $webapiHan
*/
public function getFileContent($name)
{
$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();
$curl = $this->transport;
$curl->write($this->prepareUrl($name), [], CurlTransport::GET);
$data = $curl->read();
$curl->close();
// phpcs:ignore Magento2.Security.InsecureFunction
return unserialize($data);
}

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

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 @@ -17,7 +16,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 @@ -26,21 +25,12 @@ class GeneratedCode
*/
private $transport;

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

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

/**
Expand All @@ -50,25 +40,10 @@ public function __construct(CurlTransport $transport, WebapiDecorator $webapiHan
*/
public function delete()
{
$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())
];
$url = $_ENV['app_frontend_url'] . self::URL;
$curl = $this->transport;
$curl->write($url, [], CurlInterface::GET);
$curl->read();
$curl->close();
}
}
42 changes: 8 additions & 34 deletions dev/tests/functional/lib/Magento/Mtf/Util/Command/Locales.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

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

/**
* Returns array of locales depends on fetching type.
Expand All @@ -27,7 +26,7 @@ class Locales
/**
* Url to locales.php.
*/
const URL = '/dev/tests/functional/utils/locales.php';
const URL = 'dev/tests/functional/utils/locales.php';

/**
* Curl transport protocol.
Expand All @@ -36,21 +35,12 @@ class Locales
*/
private $transport;

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

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

/**
Expand All @@ -61,28 +51,12 @@ public function __construct(CurlTransport $transport, WebapiDecorator $webapiHan
*/
public function getList($type = self::TYPE_ALL)
{
$this->transport->write(
rtrim(str_replace('index.php', '', $_ENV['app_frontend_url']), '/') . self::URL,
$this->prepareParamArray($type),
CurlInterface::POST,
[]
);
$result = $this->transport->read();
$this->transport->close();
return explode('|', $result);
}
$url = $_ENV['app_frontend_url'] . self::URL . '?type=' . $type;
$curl = $this->transport;
$curl->write($url, [], CurlInterface::GET);
$result = $curl->read();
$curl->close();

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

0 comments on commit 1d1c2ea

Please sign in to comment.