Skip to content

Commit eb83bc5

Browse files
committed
MQE-1541: Add option to generate:tests for XSD validation on 'merged files'
Changes from review comments
1 parent 27bd6b3 commit eb83bc5

File tree

11 files changed

+36
-36
lines changed

11 files changed

+36
-36
lines changed

dev/tests/_bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
true,
3333
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::UNIT_TEST_PHASE,
3434
true,
35-
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::MODE_PRODUCTION
35+
\Magento\FunctionalTestingFramework\Config\MftfApplicationConfig::DEBUG_NONE
3636
);
3737

3838
// Load needed framework env params

dev/tests/verification/Tests/SchemaValidationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SchemaValidationTest extends MftfTestCase
1919
*/
2020
public function testInvalidTestSchema()
2121
{
22-
AspectMock::double(MftfApplicationConfig::class, ['getMode' => MftfApplicationConfig::MODE_DEVELOPER]);
22+
AspectMock::double(MftfApplicationConfig::class, ['getDebugLevel' => MftfApplicationConfig::LEVEL_DEVELOPER]);
2323
$testFile = ['testFile.xml' => "<tests><test name='testName'><annotations>a</annotations></test></tests>"];
2424
$expectedError = TESTS_MODULE_PATH .
2525
DIRECTORY_SEPARATOR .

src/Magento/FunctionalTestingFramework/Config/MftfApplicationConfig.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class MftfApplicationConfig
1515
const MFTF_PHASES = [self::GENERATION_PHASE, self::EXECUTION_PHASE, self::UNIT_TEST_PHASE];
1616

1717
/**
18-
* Mftf debug modes
18+
* Mftf debug levels
1919
*/
20-
const MODE_DEFAULT = "default";
21-
const MODE_DEVELOPER = "developer";
22-
const MODE_PRODUCTION = "off";
23-
const MFTF_DEBUG_MODES = [self::MODE_DEFAULT, self::MODE_DEVELOPER, self::MODE_PRODUCTION];
20+
const LEVEL_DEFAULT = "default";
21+
const LEVEL_DEVELOPER = "developer";
22+
const DEBUG_NONE = "none";
23+
const MFTF_DEBUG_LEVEL = [self::LEVEL_DEFAULT, self::LEVEL_DEVELOPER, self::DEBUG_NONE];
2424

2525
/**
2626
* Determines whether the user has specified a force option for generation
@@ -44,11 +44,11 @@ class MftfApplicationConfig
4444
private $verboseEnabled;
4545

4646
/**
47-
* String which identifies the current debug mode of mftf execution
47+
* String which identifies the current debug level of mftf execution
4848
*
4949
* @var string
5050
*/
51-
private $mode;
51+
private $debugLevel;
5252

5353
/**
5454
* MftfApplicationConfig Singelton Instance
@@ -63,14 +63,14 @@ class MftfApplicationConfig
6363
* @param boolean $forceGenerate
6464
* @param string $phase
6565
* @param boolean $verboseEnabled
66-
* @param string $mode
66+
* @param string $debugLevel
6767
* @throws TestFrameworkException
6868
*/
6969
private function __construct(
7070
$forceGenerate = false,
7171
$phase = self::EXECUTION_PHASE,
7272
$verboseEnabled = null,
73-
$mode = self::MODE_PRODUCTION
73+
$debugLevel = self::DEBUG_NONE
7474
) {
7575
$this->forceGenerate = $forceGenerate;
7676

@@ -80,14 +80,14 @@ private function __construct(
8080

8181
$this->phase = $phase;
8282
$this->verboseEnabled = $verboseEnabled;
83-
switch ($mode) {
84-
case self::MODE_DEVELOPER:
85-
case self::MODE_DEFAULT:
86-
case self::MODE_PRODUCTION:
87-
$this->mode = $mode;
83+
switch ($debugLevel) {
84+
case self::LEVEL_DEVELOPER:
85+
case self::LEVEL_DEFAULT:
86+
case self::DEBUG_NONE:
87+
$this->debugLevel = $debugLevel;
8888
break;
8989
default:
90-
$this->mode = self::MODE_DEVELOPER;
90+
$this->debugLevel = self::LEVEL_DEVELOPER;
9191
}
9292
}
9393

@@ -98,14 +98,14 @@ private function __construct(
9898
* @param boolean $forceGenerate
9999
* @param string $phase
100100
* @param boolean $verboseEnabled
101-
* @param string $mode
101+
* @param string $debugLevel
102102
* @return void
103103
*/
104-
public static function create($forceGenerate, $phase, $verboseEnabled, $mode)
104+
public static function create($forceGenerate, $phase, $verboseEnabled, $debugLevel)
105105
{
106106
if (self::$MFTF_APPLICATION_CONTEXT == null) {
107107
self::$MFTF_APPLICATION_CONTEXT =
108-
new MftfApplicationConfig($forceGenerate, $phase, $verboseEnabled, $mode);
108+
new MftfApplicationConfig($forceGenerate, $phase, $verboseEnabled, $debugLevel);
109109
}
110110
}
111111

@@ -148,13 +148,13 @@ public function verboseEnabled()
148148
}
149149

150150
/**
151-
* Returns a string which indicates the debug mode of mftf execution.
151+
* Returns a string which indicates the debug level of mftf execution.
152152
*
153153
* @return string
154154
*/
155-
public function getMode()
155+
public function getDebugLevel()
156156
{
157-
return $this->mode ?? getenv('MFTF_DEBUG');
157+
return $this->debugLevel ?? getenv('MFTF_DEBUG');
158158
}
159159

160160
/**

src/Magento/FunctionalTestingFramework/Config/Reader/Filesystem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected function readFiles($fileList)
157157
} else {
158158
$configMerger->merge($content);
159159
}
160-
if (MftfApplicationConfig::getConfig()->getMode() === MftfApplicationConfig::MODE_DEVELOPER) {
160+
if (MftfApplicationConfig::getConfig()->getDebugLevel() === MftfApplicationConfig::LEVEL_DEVELOPER) {
161161
$this->validateSchema($configMerger, $fileList->getFilename());
162162
}
163163
} catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) {

src/Magento/FunctionalTestingFramework/Config/Reader/MftfFilesystem.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function readFiles($fileList)
2424
$exceptionCollector = new ExceptionCollector();
2525
/** @var \Magento\FunctionalTestingFramework\Test\Config\Dom $configMerger */
2626
$configMerger = null;
27-
$mode = MftfApplicationConfig::getConfig()->getMode();
27+
$debugLevel = MftfApplicationConfig::getConfig()->getDebugLevel();
2828
foreach ($fileList as $key => $content) {
2929
//check if file is empty and continue to next if it is
3030
if (!parent::verifyFileEmpty($content, $fileList->getFilename())) {
@@ -42,7 +42,7 @@ public function readFiles($fileList)
4242
$configMerger->merge($content, $fileList->getFilename(), $exceptionCollector);
4343
}
4444
// run per file validation with generate:tests -d
45-
if ($mode == MftfApplicationConfig::MODE_DEVELOPER) {
45+
if ($debugLevel == MftfApplicationConfig::LEVEL_DEVELOPER) {
4646
$this->validateSchema($configMerger, $fileList->getFilename());
4747
}
4848
} catch (\Magento\FunctionalTestingFramework\Config\Dom\ValidationException $e) {
@@ -52,7 +52,7 @@ public function readFiles($fileList)
5252
$exceptionCollector->throwException();
5353

5454
//run validation on merged file with generate:tests
55-
if ($mode == MftfApplicationConfig::MODE_DEFAULT) {
55+
if ($debugLevel == MftfApplicationConfig::LEVEL_DEFAULT) {
5656
$this->validateSchema($configMerger);
5757
}
5858

src/Magento/FunctionalTestingFramework/Console/GenerateDocsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
6767
$force,
6868
MftfApplicationConfig::GENERATION_PHASE,
6969
false,
70-
MftfApplicationConfig::MODE_PRODUCTION
70+
MftfApplicationConfig::DEBUG_NONE
7171
);
7272

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

src/Magento/FunctionalTestingFramework/Console/GenerateTestsCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ protected function configure()
5555
'debug',
5656
'd',
5757
InputOption::VALUE_OPTIONAL,
58-
'Run extra validation when generating tests. Use option \'off\' to turn off debugging --
58+
'Run extra validation when generating tests. Use option \'none\' to turn off debugging --
5959
added for backward compatibility, will be removed in the next MAJOR release',
6060
'default'
6161
);
@@ -80,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8080
$json = $input->getOption('tests');
8181
$force = $input->getOption('force');
8282
$time = $input->getOption('time') * 60 * 1000; // convert from minutes to milliseconds
83-
$mode = $input->getOption('debug');
83+
$debug = $input->getOption('debug') ?? MftfApplicationConfig::LEVEL_DEVELOPER; // for backward compatibility
8484
$remove = $input->getOption('remove');
8585
$verbose = $output->isVerbose();
8686

@@ -97,10 +97,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
9797
// Remove previous GENERATED_DIR if --remove option is used
9898
if ($remove) {
9999
$this->removeGeneratedDirectory($output, $verbose ||
100-
($mode !== MftfApplicationConfig::MODE_PRODUCTION));
100+
($debug !== MftfApplicationConfig::DEBUG_NONE));
101101
}
102102

103-
$testConfiguration = $this->createTestConfiguration($json, $tests, $force, $mode, $verbose);
103+
$testConfiguration = $this->createTestConfiguration($json, $tests, $force, $debug, $verbose);
104104

105105
// create our manifest file here
106106
$testManifest = TestManifestFactory::makeManifest($config, $testConfiguration['suites']);

src/Magento/FunctionalTestingFramework/Console/RunTestCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7575
]),
7676
'--force' => $force,
7777
'--remove' => $remove,
78-
'--debug' => MftfApplicationConfig::MODE_PRODUCTION
78+
'--debug' => MftfApplicationConfig::DEBUG_NONE
7979
];
8080
$command->run(new ArrayInput($args), $output);
8181
}

src/Magento/FunctionalTestingFramework/Console/RunTestFailedCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7272
false,
7373
MftfApplicationConfig::GENERATION_PHASE,
7474
false,
75-
MftfApplicationConfig::MODE_PRODUCTION
75+
MftfApplicationConfig::DEBUG_NONE
7676
);
7777

7878
$testConfiguration = $this->getFailedTestList();

src/Magento/FunctionalTestingFramework/Console/RunTestGroupCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7777
$force,
7878
MftfApplicationConfig::GENERATION_PHASE,
7979
false,
80-
MftfApplicationConfig::MODE_PRODUCTION
80+
MftfApplicationConfig::DEBUG_NONE
8181
);
8282

8383
if (!$skipGeneration) {

0 commit comments

Comments
 (0)