Skip to content

Commit f1dca63

Browse files
committed
MQE-1257: MFTF doctor command
- config color for console output
1 parent 9b22f48 commit f1dca63

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

docs/commands/mftf.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ vendor/bin/mftf build:project --MAGENTO_BASE_URL=http://magento.local/ --MAGENTO
113113

114114
#### Description
115115

116-
Diagnose MFTF configuration and setup
116+
Diagnose MFTF configuration and setup. Currently this command will check the following:
117+
- Admin account authentication
118+
- Verify that Selenium is up and running and available for MFTF
119+
- Verify that new session of browser can open magento admin and store front urls
120+
- Verify MagentoCLI command is setup properly
117121

118122
#### Usage
119123

src/Magento/FunctionalTestingFramework/Console/DoctorCommand.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Magento\FunctionalTestingFramework\Util\ModuleResolver;
1919
use Magento\FunctionalTestingFramework\Module\MagentoWebDriver;
2020
use Magento\FunctionalTestingFramework\Module\MagentoWebDriverDoctor;
21+
use Symfony\Component\Console\Style\SymfonyStyle;
2122

2223
class DoctorCommand extends Command
2324
{
@@ -30,11 +31,11 @@ class DoctorCommand extends Command
3031
const COLOR_RESTORE = "\e[0m";
3132

3233
/**
33-
* Command Output
34+
* Input and output SymfonyStyle
3435
*
35-
* @var OutputInterface
36+
* @var SymfonyStyle
3637
*/
37-
private $output;
38+
private $ioStyle;
3839

3940
/**
4041
* Exception Context
@@ -63,11 +64,12 @@ protected function configure()
6364
* @param OutputInterface $output
6465
* @return integer
6566
* @throws TestFrameworkException
66-
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
6767
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
6868
*/
6969
protected function execute(InputInterface $input, OutputInterface $output)
7070
{
71+
$this->ioStyle = new SymfonyStyle($input, $output);
72+
7173
$cmdStatus = true;
7274

7375
// Config application
@@ -126,14 +128,13 @@ private function checkAuthenticationToMagentoAdmin()
126128
{
127129
$result = false;
128130
try {
129-
$this->output->writeln(
130-
"\n" . self::COLOR_LIGHT_DEFAULT . "Authenticating admin account by API ..." . self::COLOR_RESTORE
131-
);
131+
$this->ioStyle->newLine();
132+
$this->ioStyle->section("Authenticating admin account by API ...");
132133
ModuleResolver::getInstance()->getAdminToken();
133-
$this->output->writeln(self::COLOR_LIGHT_GREEN . 'Successful' . self::COLOR_RESTORE);
134+
$this->ioStyle->success('Successful');
134135
$result = true;
135136
} catch (TestFrameworkException $e) {
136-
$this->output->writeln(self::COLOR_LIGHT_RED . $e->getMessage() . self::COLOR_RESTORE);
137+
$this->ioStyle->error($e->getMessage());
137138
}
138139
return $result;
139140
}
@@ -148,14 +149,15 @@ private function checkAuthenticationToMagentoAdmin()
148149
*/
149150
private function checkContextOnStep($exceptionType, $message)
150151
{
151-
$this->output->writeln("\n" . self::COLOR_LIGHT_DEFAULT. $message . self::COLOR_RESTORE);
152+
$this->ioStyle->newLine();
153+
$this->ioStyle->section($message);
152154
$this->runMagentoWebDriverDoctor();
153155

154156
if (isset($this->context[$exceptionType])) {
155-
$this->output->writeln(self::COLOR_LIGHT_RED . $this->context[$exceptionType] . self::COLOR_RESTORE);
157+
$this->ioStyle->error($this->context[$exceptionType]);
156158
return false;
157159
} else {
158-
$this->output->writeln(self::COLOR_LIGHT_GREEN . 'Successful' . self::COLOR_RESTORE);
160+
$this->ioStyle->success('Successful');
159161
return true;
160162
}
161163
}

0 commit comments

Comments
 (0)