Skip to content

Commit 8ba6d53

Browse files
authored
Merge branch 'develop' into ACQE-5710_ver1
2 parents 1066cc2 + 0a56728 commit 8ba6d53

File tree

13 files changed

+228
-39
lines changed

13 files changed

+228
-39
lines changed

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
Magento Functional Testing Framework Changelog
22
================================================
33

4+
4.6.1
5+
---------
6+
### Enhancements
7+
* Supported setting custom timeout value for `magentoCLI` command via an environment variable `MAGENTO_CLI_WAIT_TIMEOUT`.
8+
9+
4.6.0
10+
---------
11+
### Enhancements
12+
* Added Support for PHP 8.3 and enabled PR checks for PHP 8.3.
13+
* Bumped `symfony/console` dependency to `^6.0`.
14+
* Bumped `laminas/laminas-diactoros` dependency to `^3.0`.
15+
* Added no-ansi option to bin/mftf command.
16+
17+
### Fixes
18+
* Fixed 8.3 deprecation errors.
19+
* Fixed The build with PTS enabled doesn't apply filter issue.
20+
* Change MFTF command <magentoCLI> to maintain Magento CLI output.
21+
22+
4.5.0
23+
---------
24+
### Enhancements
25+
* Increase browser resolution to 1920x1080.
26+
* Add metadata to ACQE Repositories.
27+
* Add magento admin password to credentials example.
28+
29+
### Fixes
30+
* Fixed test failure while running any test suite with an argument.
31+
432
4.4.2
533
---------
634
### Fixes

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento/magento2-functional-testing-framework",
33
"description": "Magento2 Functional Testing Framework",
44
"type": "library",
5-
"version": "4.4.2",
5+
"version": "4.6.1",
66
"license": "AGPL-3.0",
77
"keywords": ["magento", "automation", "functional", "testing"],
88
"config": {

composer.lock

Lines changed: 18 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
namespace Magento\AcceptanceTest\_default\Backend;
3+
4+
use Magento\FunctionalTestingFramework\AcceptanceTester;
5+
use \Codeception\Util\Locator;
6+
use Yandex\Allure\Adapter\Annotation\Features;
7+
use Yandex\Allure\Adapter\Annotation\Stories;
8+
use Yandex\Allure\Adapter\Annotation\Title;
9+
use Yandex\Allure\Adapter\Annotation\Description;
10+
use Yandex\Allure\Adapter\Annotation\Parameter;
11+
use Yandex\Allure\Adapter\Annotation\Severity;
12+
use Yandex\Allure\Adapter\Model\SeverityLevel;
13+
use Yandex\Allure\Adapter\Annotation\TestCaseId;
14+
15+
/**
16+
* @Description("<h3>Test files</h3>verification/TestModule/Test/BasicFunctionalTest/MagentoCliTest.xml<br>")
17+
*/
18+
class MagentoCliTestCest
19+
{
20+
/**
21+
* @var bool
22+
*/
23+
private $isSuccess = false;
24+
25+
/**
26+
* @param AcceptanceTester $I
27+
* @throws \Exception
28+
*/
29+
public function _after(AcceptanceTester $I)
30+
{
31+
if ($this->isSuccess) {
32+
unlink(__FILE__);
33+
}
34+
}
35+
36+
/**
37+
* @Features({"TestModule"})
38+
* @param AcceptanceTester $I
39+
* @return void
40+
* @throws \Exception
41+
*/
42+
public function MagentoCliTest(AcceptanceTester $I)
43+
{
44+
$magentoCli1 = $I->magentoCLI("maintenance:enable", 45, "\"stuffHere\""); // stepKey: magentoCli1
45+
$I->comment($magentoCli1);
46+
$magentoCli2 = $I->magentoCLI("maintenance:enable", 120, "\"stuffHere\""); // stepKey: magentoCli2
47+
$I->comment($magentoCli2);
48+
$magentoCli3 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 45); // stepKey: magentoCli3
49+
$I->comment($magentoCli3); // stepKey: magentoCli3
50+
$magentoCli4 = $I->magentoCLISecret("config:set somePath " . $I->getSecret("someKey"), 120); // stepKey: magentoCli4
51+
$I->comment($magentoCli4); // stepKey: magentoCli4
52+
}
53+
54+
public function _passed(AcceptanceTester $I)
55+
{
56+
// Test passed successfully.
57+
$this->isSuccess = true;
58+
}
59+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="MagentoCliTest">
11+
<magentoCLI command="maintenance:enable" arguments="&quot;stuffHere&quot;" stepKey="magentoCli1"/>
12+
<magentoCLI command="maintenance:enable" arguments="&quot;stuffHere&quot;" timeout="120" stepKey="magentoCli2"/>
13+
<magentoCLI command="config:set somePath {{_CREDS.someKey}}" stepKey="magentoCli3"/>
14+
<magentoCLI command="config:set somePath {{_CREDS.someKey}}" timeout="120" stepKey="magentoCli4"/>
15+
</test>
16+
</tests>

dev/tests/verification/Tests/BasicCestGenerationTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,17 @@ public function testWithXmlComments()
5959
{
6060
$this->generateAndCompareTest('XmlCommentedTest');
6161
}
62+
63+
/**
64+
* Tests magentoCLI and magentoCLISecret commands with env 'MAGENTO_CLI_WAIT_TIMEOUT' set
65+
*
66+
* @throws \Exception
67+
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
68+
*/
69+
public function testMagentoCli()
70+
{
71+
putenv("MAGENTO_CLI_WAIT_TIMEOUT=45");
72+
$this->generateAndCompareTest('MagentoCliTest');
73+
putenv("MAGENTO_CLI_WAIT_TIMEOUT");
74+
}
6275
}

etc/config/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ MODULE_ALLOWLIST=Magento_Framework,ConfigurableProductWishlist,ConfigurableProdu
6161
#*** Default timeout for wait actions
6262
WAIT_TIMEOUT=60
6363

64+
#*** Default timeout for 'magentoCLI' and 'magentoCLISecret' command
65+
MAGENTO_CLI_WAIT_TIMEOUT=60
66+
6467
#*** Uncomment and set to enable all tests, regardless of passing status, to have all their Allure artifacts.
6568
#VERBOSE_ARTIFACTS=true
6669

etc/config/command.php

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,16 @@
4646
$idleTimeout = true;
4747
}
4848

49-
if (checkForFilePath($output)) {
50-
$output = "CLI output suppressed, filepath detected in output.";
51-
}
52-
5349
$exitCode = $process->getExitCode();
5450

5551
if ($process->isSuccessful() || $idleTimeout) {
5652
http_response_code(202);
5753
} else {
5854
http_response_code(500);
5955
}
60-
echo $output;
56+
57+
// Suppress file paths from output
58+
echo suppressFilePaths($output);
6159
} else {
6260
http_response_code(403);
6361
echo "Given command not found valid in Magento CLI Command list.";
@@ -115,11 +113,21 @@ function trimAfterWhitespace($string)
115113
}
116114

117115
/**
118-
* Detects file path in string.
116+
* Suppress file paths in string.
119117
* @param string $string
120-
* @return boolean
118+
* @return string
121119
*/
122-
function checkForFilePath($string)
120+
function suppressFilePaths(string $string): string
123121
{
124-
return preg_match('/\/[\S]+\//', $string);
122+
// Match file paths on both *nix and Windows system
123+
$filePathPattern = '~(?:[A-Za-z]:[\\\/]|\\\\|\/)\S+~';
124+
$replacement = '[suppressed_path]';
125+
126+
preg_match_all($filePathPattern, $string, $matches);
127+
if (!empty($matches)) {
128+
foreach ($matches[0] as $match) {
129+
$string = str_replace($match, $replacement, $string);
130+
}
131+
}
132+
return $string;
125133
}

src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
252252
// check test dependencies log command
253253
if (!empty($log)) {
254254
if ($log === "testEntityJson") {
255-
$this->getTestEntityJson($tests);
255+
$this->getTestEntityJson($filterList ??[], $tests);
256256
$testDependencyFileLocation = self::TEST_DEPENDENCY_FILE_LOCATION_EMBEDDED;
257257
if (isset($_ENV['MAGENTO_BP'])) {
258258
$testDependencyFileLocation = self::TEST_DEPENDENCY_FILE_LOCATION_STANDALONE;
@@ -395,21 +395,22 @@ private function parseConfigParallelOptions($time, $groups)
395395
* @throws TestFrameworkException
396396
* @throws XmlException|FastFailException
397397
*/
398-
private function getTestEntityJson(array $tests = [])
398+
private function getTestEntityJson(array $filterList, array $tests = [])
399399
{
400-
$testDependencies = $this->getTestDependencies($tests);
400+
$testDependencies = $this->getTestDependencies($filterList, $tests);
401401
$this->array2Json($testDependencies);
402402
}
403403

404404
/**
405405
* Function responsible for getting test dependencies in array
406+
* @param array $filterList
406407
* @param array $tests
407408
* @return array
408409
* @throws FastFailException
409410
* @throws TestFrameworkException
410411
* @throws XmlException
411412
*/
412-
public function getTestDependencies(array $tests = []): array
413+
public function getTestDependencies(array $filterList, array $tests = []): array
413414
{
414415
$this->scriptUtil = new ScriptUtil();
415416
$this->testDependencyUtil = new TestDependencyUtil();
@@ -442,7 +443,11 @@ public function getTestDependencies(array $tests = []): array
442443
}
443444

444445
list($testDependencies, $extendedTestMapping) = $this->findTestDependentModule($testXmlFiles);
445-
return $this->testDependencyUtil->mergeDependenciesForExtendingTests($testDependencies, $extendedTestMapping);
446+
return $this->testDependencyUtil->mergeDependenciesForExtendingTests(
447+
$testDependencies,
448+
$filterList,
449+
$extendedTestMapping
450+
);
446451
}
447452

448453
/**

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,9 +530,9 @@ public function scrollToTopOfPage()
530530
/**
531531
* Takes given $command and executes it against bin/magento or custom exposed entrypoint. Returns command output.
532532
*
533-
* @param string $command
534-
* @param integer $timeout
535-
* @param string $arguments
533+
* @param string $command
534+
* @param integer|null $timeout
535+
* @param string|null $arguments
536536
* @return string
537537
*
538538
* @throws TestFrameworkException
@@ -846,9 +846,9 @@ public function fillSecretField($field, $value)
846846
* Function used to create data that contains sensitive credentials in a <createData> <field> override.
847847
* The data is decrypted immediately prior to data creation to avoid exposure in console or log.
848848
*
849-
* @param string $command
850-
* @param null $timeout
851-
* @param null $arguments
849+
* @param string $command
850+
* @param integer|null $timeout
851+
* @param string|null $arguments
852852
* @throws TestFrameworkException
853853
* @return string
854854
*/

0 commit comments

Comments
 (0)