Skip to content

Commit 012f56f

Browse files
authored
MQE-917: Eliminate usage of XSD relative paths
- Added --force flag if user does not have a misc.xml file.
1 parent 5733a1b commit 012f56f

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/Magento/FunctionalTestingFramework/Console/GenerateDevUrnCommand.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Symfony\Component\Console\Input\InputArgument;
1414
use Symfony\Component\Console\Input\InputInterface;
1515
use Symfony\Component\Console\Output\OutputInterface;
16+
use Symfony\Component\Console\Input\InputOption;
17+
use Magento\FunctionalTestingFramework\Util\Logger\LoggingUtil;
1618

1719
class GenerateDevUrnCommand extends Command
1820
{
@@ -25,7 +27,13 @@ protected function configure()
2527
{
2628
$this->setName('generate:urn-catalog')
2729
->setDescription('This command generates an URN catalog to enable PHPStorm to recognize and highlight URNs.')
28-
->addArgument('path', InputArgument::REQUIRED, 'path to PHPStorm misc.xml file (typically located in [ProjectRoot]/.idea/misc.xml)');
30+
->addArgument('path', InputArgument::REQUIRED, 'path to PHPStorm misc.xml file (typically located in [ProjectRoot]/.idea/misc.xml)')
31+
->addOption(
32+
"force",
33+
'f',
34+
InputOption::VALUE_NONE,
35+
'forces creation of misc.xml file if not found in the path given.'
36+
);
2937
}
3038

3139
/**
@@ -40,12 +48,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
4048
{
4149
$miscXmlFilePath = $input->getArgument('path') . DIRECTORY_SEPARATOR . "misc.xml";
4250
$miscXmlFile = realpath($miscXmlFilePath);
51+
$force = $input->getOption('force');
4352

4453
if ($miscXmlFile === false) {
45-
$exceptionMessage = "misc.xml not found in given path '{$miscXmlFilePath}'";
46-
LoggingUtil::getInstance()->getLogger(GenerateDevUrnCommand::class)
47-
->error($exceptionMessage);
48-
throw new TestFrameworkException($exceptionMessage);
54+
if ($force == true) {
55+
// create file and refresh realpath
56+
$xml = "<project version=\"4\"/>";
57+
file_put_contents($miscXmlFilePath, $xml);
58+
$miscXmlFile = realpath($miscXmlFilePath);
59+
} else {
60+
$exceptionMessage = "misc.xml not found in given path '{$miscXmlFilePath}'";
61+
LoggingUtil::getInstance()->getLogger(GenerateDevUrnCommand::class)
62+
->error($exceptionMessage);
63+
throw new TestFrameworkException($exceptionMessage);
64+
}
4965
}
5066
$dom = new \DOMDocument('1.0');
5167
$dom->preserveWhiteSpace = false;

0 commit comments

Comments
 (0)