9 use Magento\Mtf\Config\DataInterface;
10 use Magento\Mtf\ObjectManagerInterface;
11 use Symfony\Component\Console\Input\InputInterface;
12 use Symfony\Component\Console\Output\OutputInterface;
24 private $configFilePath =
MTF_BP . DIRECTORY_SEPARATOR .
'etc' . DIRECTORY_SEPARATOR .
'config.xml';
31 private $objectManager;
45 private $configXmlDist;
53 ObjectManagerInterface $objectManager,
54 DataInterface $configXml,
55 DataInterface $configXmlDist
57 parent::__construct();
59 $this->configXml = $configXml->get();
60 $this->configXmlDist = $configXmlDist->get();
71 $this->setName(
'troubleshooting:check-config-valid')
72 ->setDescription(
'Check if config.xml is configured properly.');
85 $output = $this->objectManager->create(
89 $output->writeln(
"Checking config.xml file configuration...");
90 $output->outputMessages($this->checkConfigFileAvailable());
91 $output->writeln(
"config.xml file check is finished.");
99 private function checkConfigFileAvailable()
102 $configFileExists =
false;
103 if (file_exists($this->configFilePath)) {
104 $configFileExists =
true;
105 if ($this->recursiveKeys($this->configXml) != $this->recursiveKeys($this->configXmlDist)) {
106 $messages[
'error'][] =
'Check your config.xml file to contain all configs from config.xml.dist.';
109 if (file_exists($this->configFilePath .
'.dist')) {
110 if (!copy($this->configFilePath .
'.dist', $this->configFilePath)) {
111 $messages[
'error'][] =
'Failed to copy config.xml.dist to config.xml.';
114 $messages[
'info'][] =
'config.xml file has been created based on config.xml.dist.';
115 $configFileExists =
true;
118 if (!$configFileExists) {
119 $messages[
'error'][] =
'Cannot define config.xml configuration path.';
130 private function recursiveKeys(array $input)
133 foreach ($input as $sub) {
134 if (is_array($sub)) {
execute(InputInterface $input, OutputInterface $output)
defined('MTF_TESTS_PATH')||define('MTF_TESTS_PATH' MTF_BP
__construct(ObjectManagerInterface $objectManager, DataInterface $configXml, DataInterface $configXmlDist)