Skip to content

Commit 3f6bb8c

Browse files
authored
Merge pull request #450 from magento/MQE-1754
Mqe 1754 mftf generate:tests AdminLoginTest -f does not obey the -f flag
2 parents 03c1f19 + 02f073b commit 3f6bb8c

8 files changed

+66
-33
lines changed

src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,13 @@ private function __construct(
115115
* @return void
116116
* @throws TestFrameworkException
117117
*/
118-
public static function create($forceGenerate, $phase, $verboseEnabled, $debugLevel, $allowSkipped)
119-
{
118+
public static function create(
119+
$forceGenerate = false,
120+
$phase = self::EXECUTION_PHASE,
121+
$verboseEnabled = null,
122+
$debugLevel = self::LEVEL_NONE,
123+
$allowSkipped = false
124+
) {
120125
if (self::$MFTF_APPLICATION_CONTEXT == null) {
121126
self::$MFTF_APPLICATION_CONTEXT =
122127
new MftfApplicationConfig($forceGenerate, $phase, $verboseEnabled, $debugLevel, $allowSkipped);

src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767
$force,
6868
MftfApplicationConfig::GENERATION_PHASE,
6969
false,
70-
MftfApplicationConfig::LEVEL_NONE
70+
MftfApplicationConfig::LEVEL_NONE,
71+
true
7172
);
7273

7374
$allActionGroups = ActionGroupObjectHandler::getInstance()->getAllObjects();

src/Magento/FunctionalTestingFramework/Console/GenerateSuiteCommand.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,20 @@ protected function configure()
4242
*/
4343
protected function execute(InputInterface $input, OutputInterface $output)
4444
{
45+
$force = $input->getOption('force');
46+
$debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility
4547
$remove = $input->getOption('remove');
48+
$verbose = $output->isVerbose();
49+
$allowSkipped = $input->getOption('allowSkipped');
50+
51+
// Set application configuration so we can references the user options in our framework
52+
MftfApplicationConfig::create(
53+
$force,
54+
MftfApplicationConfig::GENERATION_PHASE,
55+
$verbose,
56+
$debug,
57+
$allowSkipped
58+
);
4659

4760
// Remove previous GENERATED_DIR if --remove option is used
4861
if ($remove) {

src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
7373
$verbose = $output->isVerbose();
7474
$allowSkipped = $input->getOption('allowSkipped');
7575

76+
// Set application configuration so we can references the user options in our framework
77+
MftfApplicationConfig::create(
78+
$force,
79+
MftfApplicationConfig::GENERATION_PHASE,
80+
$verbose,
81+
$debug,
82+
$allowSkipped
83+
);
84+
7685
if (!empty($tests)) {
7786
$json = $this->getTestAndSuiteConfiguration($tests);
7887
}
@@ -93,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
93102
($debug !== MftfApplicationConfig::LEVEL_NONE));
94103
}
95104

96-
$testConfiguration = $this->createTestConfiguration($json, $tests, $force, $debug, $verbose, $allowSkipped);
105+
$testConfiguration = $this->createTestConfiguration($json, $tests);
97106

98107
// create our manifest file here
99108
$testManifest = TestManifestFactory::makeManifest($config, $testConfiguration['suites']);
@@ -114,33 +123,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
114123
/**
115124
* Function which builds up a configuration including test and suites for consumption of Magento generation methods.
116125
*
117-
* @param string $json
118-
* @param array $tests
119-
* @param boolean $force
120-
* @param string $debug
121-
* @param boolean $verbose
122-
* @param boolean $allowSkipped
126+
* @param string $json
127+
* @param array $tests
123128
* @return array
124129
* @throws \Magento\FunctionalTestingFramework\Exceptions\TestReferenceException
125130
* @throws \Magento\FunctionalTestingFramework\Exceptions\XmlException
126131
*/
127132
private function createTestConfiguration(
128133
$json,
129-
array $tests,
130-
bool $force,
131-
string $debug,
132-
bool $verbose,
133-
bool $allowSkipped
134+
array $tests
134135
) {
135-
// set our application configuration so we can references the user options in our framework
136-
MftfApplicationConfig::create(
137-
$force,
138-
MftfApplicationConfig::GENERATION_PHASE,
139-
$verbose,
140-
$debug,
141-
$allowSkipped
142-
);
143-
144136
$testConfiguration = [];
145137
$testConfiguration['tests'] = $tests;
146138
$testConfiguration['suites'] = [];

src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ protected function configure()
3232
'name',
3333
InputArgument::REQUIRED | InputArgument::IS_ARRAY,
3434
"name of tests to generate and execute"
35-
)->addOption('skip-generate', 'k', InputOption::VALUE_NONE, "skip generation and execute existing test");
35+
)->addOption(
36+
'skip-generate',
37+
'k',
38+
InputOption::VALUE_NONE,
39+
"skip generation and execute existing test"
40+
);
3641

3742
parent::configure();
3843
}
@@ -55,6 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5560
$remove = $input->getOption('remove');
5661
$debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility
5762
$allowSkipped = $input->getOption('allowSkipped');
63+
$verbose = $output->isVerbose();
5864

5965
if ($skipGeneration and $remove) {
6066
// "skip-generate" and "remove" options cannot be used at the same time
@@ -63,6 +69,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6369
);
6470
}
6571

72+
// Set application configuration so we can references the user options in our framework
73+
MftfApplicationConfig::create(
74+
$force,
75+
MftfApplicationConfig::EXECUTION_PHASE,
76+
$verbose,
77+
$debug,
78+
$allowSkipped
79+
);
80+
6681
$testConfiguration = $this->getTestAndSuiteConfiguration($tests);
6782

6883
if (!$skipGeneration) {
@@ -72,7 +87,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7287
'--force' => $force,
7388
'--remove' => $remove,
7489
'--debug' => $debug,
75-
'--allowSkipped' => $allowSkipped
90+
'--allowSkipped' => $allowSkipped,
91+
'-v' => $verbose
7692
];
7793
$command->run(new ArrayInput($args), $output);
7894
}

src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7171
$force = $input->getOption('force');
7272
$debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility
7373
$allowSkipped = $input->getOption('allowSkipped');
74+
$verbose = $output->isVerbose();
7475

7576
// Create Mftf Configuration
7677
MftfApplicationConfig::create(
7778
$force,
78-
MftfApplicationConfig::GENERATION_PHASE,
79-
false,
79+
MftfApplicationConfig::EXECUTION_PHASE,
80+
$verbose,
8081
$debug,
8182
$allowSkipped
8283
);
@@ -91,9 +92,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9192
$command = $this->getApplication()->find('generate:tests');
9293
$args = [
9394
'--tests' => $testConfiguration,
95+
'--force' => $force,
9496
'--remove' => true,
9597
'--debug' => $debug,
96-
'--allowSkipped' => $allowSkipped
98+
'--allowSkipped' => $allowSkipped,
99+
'-v' => $verbose
97100
];
98101
$command->run(new ArrayInput($args), $output);
99102

src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6161
$remove = $input->getOption('remove');
6262
$debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility
6363
$allowSkipped = $input->getOption('allowSkipped');
64+
$verbose = $output->isVerbose();
6465

6566
if ($skipGeneration and $remove) {
6667
// "skip-generate" and "remove" options cannot be used at the same time
@@ -72,8 +73,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7273
// Create Mftf Configuration
7374
MftfApplicationConfig::create(
7475
$force,
75-
MftfApplicationConfig::GENERATION_PHASE,
76-
false,
76+
MftfApplicationConfig::EXECUTION_PHASE,
77+
$verbose,
7778
$debug,
7879
$allowSkipped
7980
);
@@ -86,7 +87,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8687
'--force' => $force,
8788
'--remove' => $remove,
8889
'--debug' => $debug,
89-
'--allowSkipped' => $allowSkipped
90+
'--allowSkipped' => $allowSkipped,
91+
'-v' => $verbose
9092
];
9193

9294
$command->run(new ArrayInput($args), $output);

src/Magento/FunctionalTestingFramework/StaticCheck/TestDependencyCheck.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public function execute(InputInterface $input)
8888
true,
8989
MftfApplicationConfig::UNIT_TEST_PHASE,
9090
false,
91-
MftfApplicationConfig::LEVEL_NONE
91+
MftfApplicationConfig::LEVEL_NONE,
92+
true
9293
);
9394

9495
ModuleResolver::getInstance()->getModulesPath();

0 commit comments

Comments
 (0)