diff --git a/CHANGELOG.md b/CHANGELOG.md index 555942bd3..9181108ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Magento Functional Testing Framework Changelog ================================================ +4.6.1 +--------- +### Enhancements +* Supported setting custom timeout value for `magentoCLI` command via an environment variable `MAGENTO_CLI_WAIT_TIMEOUT`. + 4.6.0 --------- ### Enhancements diff --git a/composer.json b/composer.json index ac0c8a43d..468756b45 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "magento/magento2-functional-testing-framework", "description": "Magento2 Functional Testing Framework", "type": "library", - "version": "4.6.0", + "version": "4.6.1", "license": "AGPL-3.0", "keywords": ["magento", "automation", "functional", "testing"], "config": { diff --git a/composer.lock b/composer.lock index 311e13e11..c86a5d45c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a0ebd24d0c275a654005c55f65b58e22", + "content-hash": "7772662f5957bac06547b5d62352d5d6", "packages": [ { "name": "allure-framework/allure-codeception", @@ -7996,12 +7996,12 @@ "version": "3.7.2", "source": { "type": "git", - "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/ed8e00df0a83aa96acf703f8c2979ff33341f879", "reference": "ed8e00df0a83aa96acf703f8c2979ff33341f879", "shasum": "" }, @@ -8046,6 +8046,20 @@ "source": "https://github.com/squizlabs/PHP_CodeSniffer", "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + } + ], "time": "2023-02-22T23:07:41+00:00" }, { @@ -8356,5 +8370,5 @@ "ext-openssl": "*" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" } diff --git a/dev/tests/verification/Resources/MagentoCliTest.txt b/dev/tests/verification/Resources/MagentoCliTest.txt new file mode 100644 index 000000000..3efc73c01 --- /dev/null +++ b/dev/tests/verification/Resources/MagentoCliTest.txt @@ -0,0 +1,59 @@ +Test filesverification/TestModule/Test/BasicFunctionalTest/MagentoCliTest.xml
") + */ +class MagentoCliTestCest +{ + /** + * @var bool + */ + private $isSuccess = false; + + /** + * @param AcceptanceTester $I + * @throws \Exception + */ + public function _after(AcceptanceTester $I) + { + if ($this->isSuccess) { + unlink(__FILE__); + } + } + + /** + * @Features({"TestModule"}) + * @param AcceptanceTester $I + * @return void + * @throws \Exception + */ + public function MagentoCliTest(AcceptanceTester $I) + { + $magentoCli1 = $I->magentoCLI("maintenance:enable", 45, "\"stuffHere\""); // stepKey: magentoCli1 + $I->comment($magentoCli1); + $magentoCli2 = $I->magentoCLI("maintenance:enable", 120, "\"stuffHere\""); // stepKey: magentoCli2 + $I->comment($magentoCli2); + $magentoCli3 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 45); // stepKey: magentoCli3 + $I->comment($magentoCli3); // stepKey: magentoCli3 + $magentoCli4 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 120); // stepKey: magentoCli4 + $I->comment($magentoCli4); // stepKey: magentoCli4 + } + + public function _passed(AcceptanceTester $I) + { + // Test passed successfully. + $this->isSuccess = true; + } +} diff --git a/dev/tests/verification/TestModule/Test/BasicFunctionalTest/MagentoCliTest.xml b/dev/tests/verification/TestModule/Test/BasicFunctionalTest/MagentoCliTest.xml new file mode 100644 index 000000000..23914943a --- /dev/null +++ b/dev/tests/verification/TestModule/Test/BasicFunctionalTest/MagentoCliTest.xml @@ -0,0 +1,16 @@ + + + + + + + + + + diff --git a/dev/tests/verification/Tests/BasicCestGenerationTest.php b/dev/tests/verification/Tests/BasicCestGenerationTest.php index 39802c50d..a900edbd3 100644 --- a/dev/tests/verification/Tests/BasicCestGenerationTest.php +++ b/dev/tests/verification/Tests/BasicCestGenerationTest.php @@ -59,4 +59,17 @@ public function testWithXmlComments() { $this->generateAndCompareTest('XmlCommentedTest'); } + + /** + * Tests magentoCLI and magentoCLISecret commands with env 'MAGENTO_CLI_WAIT_TIMEOUT' set + * + * @throws \Exception + * @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException + */ + public function testMagentoCli() + { + putenv("MAGENTO_CLI_WAIT_TIMEOUT=45"); + $this->generateAndCompareTest('MagentoCliTest'); + putenv("MAGENTO_CLI_WAIT_TIMEOUT"); + } } diff --git a/etc/config/.env.example b/etc/config/.env.example index 3291d1082..b3ec2ad41 100644 --- a/etc/config/.env.example +++ b/etc/config/.env.example @@ -61,6 +61,9 @@ MODULE_ALLOWLIST=Magento_Framework,ConfigurableProductWishlist,ConfigurableProdu #*** Default timeout for wait actions WAIT_TIMEOUT=60 +#*** Default timeout for 'magentoCLI' and 'magentoCLISecret' command +MAGENTO_CLI_WAIT_TIMEOUT=60 + #*** Uncomment and set to enable all tests, regardless of passing status, to have all their Allure artifacts. #VERBOSE_ARTIFACTS=true diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index f2580deaf..057876659 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -530,9 +530,9 @@ public function scrollToTopOfPage() /** * Takes given $command and executes it against bin/magento or custom exposed entrypoint. Returns command output. * - * @param string $command - * @param integer $timeout - * @param string $arguments + * @param string $command + * @param integer|null $timeout + * @param string|null $arguments * @return string * * @throws TestFrameworkException @@ -846,9 +846,9 @@ public function fillSecretField($field, $value) * Function used to create data that contains sensitive credentials in a override. * The data is decrypted immediately prior to data creation to avoid exposure in console or log. * - * @param string $command - * @param null $timeout - * @param null $arguments + * @param string $command + * @param integer|null $timeout + * @param string|null $arguments * @throws TestFrameworkException * @return string */ diff --git a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php index 451b58aa0..d8ed23098 100644 --- a/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php +++ b/src/Magento/FunctionalTestingFramework/Test/Objects/ActionObject.php @@ -184,6 +184,17 @@ public static function getDefaultWaitTimeout() return getenv('WAIT_TIMEOUT'); } + /** + * Retrieve default timeout for 'magentoCLI' or 'magentoCLISecret' in seconds + * + * @return integer + */ + public static function getDefaultMagentoCLIWaitTimeout() + { + $timeout = getenv('MAGENTO_CLI_WAIT_TIMEOUT'); + return !empty($timeout) ? $timeout : self::DEFAULT_COMMAND_WAIT_TIMEOUT; + } + /** * This function returns the string property stepKey. * diff --git a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php index 0dfb0f8ee..46a05c946 100644 --- a/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php +++ b/src/Magento/FunctionalTestingFramework/Util/TestGenerator.php @@ -842,7 +842,7 @@ public function generateStepsPhp($actionObjects, $generationScope = TestGenerato } if (in_array($actionObject->getType(), ActionObject::COMMAND_ACTION_ATTRIBUTES)) { - $time = $time ?? ActionObject::DEFAULT_COMMAND_WAIT_TIMEOUT; + $time = $time ?? ActionObject::getDefaultMagentoCLIWaitTimeout(); } else { $time = $time ?? ActionObject::getDefaultWaitTimeout(); }