diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php index 350c9585d15fd..54398f8bf9dc7 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli.php @@ -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); @@ -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); diff --git a/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/Cache.php b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/Cache.php index 272e3158d3c27..4b0fc013d04ec 100644 --- a/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/Cache.php +++ b/dev/tests/functional/lib/Magento/Mtf/Util/Command/Cli/Cache.php @@ -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. */ @@ -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); } /** @@ -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" : '')); } /** @@ -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" : '')); } } diff --git a/dev/tests/functional/tests/app/Magento/Config/Test/TestStep/SetupConfigurationStep.php b/dev/tests/functional/tests/app/Magento/Config/Test/TestStep/SetupConfigurationStep.php index a1f3996197517..b5df8040b575d 100644 --- a/dev/tests/functional/tests/app/Magento/Config/Test/TestStep/SetupConfigurationStep.php +++ b/dev/tests/functional/tests/app/Magento/Config/Test/TestStep/SetupConfigurationStep.php @@ -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. @@ -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(); diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php index 406d31a03d56c..f220109f86ca6 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.php @@ -67,6 +67,13 @@ class CreateConfigurableProductEntityTest extends Injectable */ protected $testStepFactory; + /** + * Configuration data holder. + * + * @var string + */ + protected $configData = null; + /** * Injection data. * @@ -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(); @@ -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(); } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml index b431c4841d7ab..2e86dd00971a1 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/TestCase/CreateConfigurableProductEntityTest.xml @@ -140,7 +140,7 @@ default_subcategory configurable-product-%isolation% custom_attribute_set_%isolation% - true + display_out_of_stock_products @@ -158,7 +158,7 @@ default_subcategory configurable-product-%isolation% custom_attribute_set_%isolation% - true + display_out_of_stock_products @@ -176,7 +176,7 @@ default_subcategory configurable-product-%isolation% custom_attribute_set_%isolation% - true + display_out_of_stock_products diff --git a/dev/tests/functional/utils/command.php b/dev/tests/functional/utils/command.php index 397f60cd07ea1..fd99536659423 100644 --- a/dev/tests/functional/utils/command.php +++ b/dev/tests/functional/utils/command.php @@ -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."); }