Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/MAGETWO-65339' into MAGETWO-65339
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaVasyltsun committed Mar 10, 2017
2 parents d18cc7b + 0068910 commit 78296ef
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 22 deletions.
6 changes: 3 additions & 3 deletions dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(CurlTransport $transport)
* @param array $options [optional]
* @return void
*/
protected function execute($command, $options = [])
public function execute($command, $options = [])
{
$curl = $this->transport;
$curl->write($this->prepareUrl($command, $options), [], CurlInterface::GET);
Expand All @@ -53,10 +53,10 @@ protected function execute($command, $options = [])
* Prepare url.
*
* @param string $command
* @param array $options
* @param array $options [optional]
* @return string
*/
private function prepareUrl($command, array $options)
private function prepareUrl($command, $options = [])
{
$command .= ' ' . implode(' ', $options);
return $_ENV['app_frontend_url'] . self::URL . '?command=' . urlencode($command);
Expand Down
24 changes: 20 additions & 4 deletions dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,24 @@
/**
* Handle cache for tests executions.
*/
class Cache extends Cli
class Cache
{
/**
* Perform bin/magento commands from command line for functional tests executions.
*
* @var Cli
*/
private $cli;

/**
* Cache constructor.
* @param Cli $cli
*/
public function __construct(Cli $cli)
{
$this->cli = $cli;
}

/**
* Parameter for flush cache command.
*/
Expand All @@ -38,7 +54,7 @@ class Cache extends Cli
public function flush(array $cacheTypes = [])
{
$options = empty($cacheTypes) ? '' : ' ' . implode(' ', $cacheTypes);
parent::execute(Cache::PARAM_CACHE_FLUSH . $options);
$this->cli->execute(Cache::PARAM_CACHE_FLUSH . $options);
}

/**
Expand All @@ -49,7 +65,7 @@ public function flush(array $cacheTypes = [])
*/
public function disableCache($cacheType = null)
{
parent::execute(Cache::PARAM_CACHE_DISABLE . ($cacheType ? " $cacheType" : ''));
$this->cli->execute(Cache::PARAM_CACHE_DISABLE . ($cacheType ? " $cacheType" : ''));
}

/**
Expand All @@ -60,6 +76,6 @@ public function disableCache($cacheType = null)
*/
public function enableCache($cacheType = null)
{
parent::execute(Cache::PARAM_CACHE_ENABLE . ($cacheType ? " $cacheType" : ''));
$this->cli->execute(Cache::PARAM_CACHE_ENABLE . ($cacheType ? " $cacheType" : ''));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ class SetupConfigurationStep implements TestStepInterface
protected $rollback;

/**
* Flush cache.
* Flush cache after change config flag.
*
* @var bool
*/
protected $flushCache;
private $flushCache;

/**
* Cli command to do operations with cache.
Expand Down Expand Up @@ -94,7 +94,7 @@ public function run()
$config = $this->fixtureFactory->createByCode('configData', ['dataset' => $configDataSet . $prefix]);
if ($config->hasData('section')) {
$config->persist();
$result = array_merge($result, $config->getSection());
$result = array_replace_recursive($result, $config->getSection());
}
if ($this->flushCache) {
$this->cache->flush();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ class CreateConfigurableProductEntityTest extends Injectable
*/
protected $testStepFactory;

/**
* Configuration data holder.
*
* @var string
*/
protected $configData = null;

/**
* Injection data.
*
Expand All @@ -89,17 +96,17 @@ public function __inject(
* Test create catalog Configurable product run.
*
* @param ConfigurableProduct $product
* @param string|null $configData
* @return void
*/
public function test(ConfigurableProduct $product, $displayOutOfStockProducts = false)
public function test(ConfigurableProduct $product, $configData = null)
{
//Preconditions
if ($displayOutOfStockProducts) {
$this->testStepFactory->create(
SetupConfigurationStep::class,
['configData' => 'display_out_of_stock_products', 'flushCache' => true]
)->run();
}
$this->configData = $configData;
$this->testStepFactory->create(
SetupConfigurationStep::class,
['configData' => $this->configData, 'flushCache' => true]
)->run();

// Steps
$this->productIndex->open();
Expand All @@ -115,7 +122,7 @@ public function teatDown()
{
$this->testStepFactory->create(
SetupConfigurationStep::class,
['configData' => 'display_out_of_stock_products', 'flushCache' => true]
['configData' => $this->configData, 'flushCache' => true]
)->cleanUp();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
<data name="product/data/category_ids/dataset" xsi:type="string">default_subcategory</data>
<data name="product/data/url_key" xsi:type="string">configurable-product-%isolation%</data>
<data name="product/data/affected_attribute_set" xsi:type="string">custom_attribute_set_%isolation%</data>
<data name="displayOutOfStockProducts">true</data>
<data name="configData">display_out_of_stock_products</data>
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductForm" />
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableAttributesBlockIsAbsentOnProductPage" />
Expand All @@ -158,7 +158,7 @@
<data name="product/data/category_ids/dataset" xsi:type="string">default_subcategory</data>
<data name="product/data/url_key" xsi:type="string">configurable-product-%isolation%</data>
<data name="product/data/affected_attribute_set" xsi:type="string">custom_attribute_set_%isolation%</data>
<data name="displayOutOfStockProducts">true</data>
<data name="configData">display_out_of_stock_products</data>
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductForm" />
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableAttributesBlockIsAbsentOnProductPage" />
Expand All @@ -176,7 +176,7 @@
<data name="product/data/category_ids/dataset" xsi:type="string">default_subcategory</data>
<data name="product/data/url_key" xsi:type="string">configurable-product-%isolation%</data>
<data name="product/data/affected_attribute_set" xsi:type="string">custom_attribute_set_%isolation%</data>
<data name="displayOutOfStockProducts">true</data>
<data name="configData">display_out_of_stock_products</data>
<constraint name="Magento\Catalog\Test\Constraint\AssertProductSaveMessage" />
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableProductForm" />
<constraint name="Magento\ConfigurableProduct\Test\Constraint\AssertConfigurableAttributesBlockIsAbsentOnProductPage" />
Expand Down
10 changes: 9 additions & 1 deletion dev/tests/functional/utils/command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
* See COPYING.txt for license details.
*/

$commandList = [
'cache:flush',
'cache:disable',
'cache:enable',
];

if (isset($_GET['command'])) {
$command = urldecode($_GET['command']);
exec('php -f ../../../../bin/magento ' . $command);
if (in_array($command, $commandList)) {
exec('php -f ../../../../bin/magento ' . $command);
}
} else {
throw new \InvalidArgumentException("Command GET parameter is not set.");
}

0 comments on commit 78296ef

Please sign in to comment.