Skip to content

Commit 4908777

Browse files
committed
MQE-1257: MFTF doctor command
- config color for console output
1 parent 25c5706 commit 4908777

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/Magento/FunctionalTestingFramework/Console/DoctorCommand.php

+14-11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ class DoctorCommand extends Command
2424
const CODECEPTION_AUTOLOAD_FILE = PROJECT_ROOT . '/vendor/codeception/codeception/autoload.php';
2525
const MFTF_CODECEPTION_CONFIG_FILE = ENV_FILE_PATH . 'codeception.yml';
2626
const SUITE = 'functional';
27+
const COLOR_LIGHT_GREEN = "\e[1;32m";
28+
const COLOR_LIGHT_RED = "\e[1;31m";
29+
const COLOR_LIGHT_DEFAULT = "\e[1;39m";
30+
const COLOR_RESTORE = "\e[0m";
2731

2832
/**
2933
* Command Output
@@ -60,6 +64,7 @@ protected function configure()
6064
* @return integer
6165
* @throws TestFrameworkException
6266
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
67+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
6368
*/
6469
protected function execute(InputInterface $input, OutputInterface $output)
6570
{
@@ -109,11 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
109114
);
110115
$cmdStatus = $cmdStatus && !$status ? false : $cmdStatus;
111116

112-
if ($cmdStatus) {
113-
return 0;
114-
} else {
115-
return 1;
116-
}
117+
return $cmdStatus ? 0 : 1;
117118
}
118119

119120
/**
@@ -125,12 +126,14 @@ private function checkAuthenticationToMagentoAdmin()
125126
{
126127
$result = false;
127128
try {
128-
$this->output->writeln("\nAuthenticating admin account by API ...");
129+
$this->output->writeln(
130+
"\n" . self::COLOR_LIGHT_DEFAULT . "Authenticating admin account by API ..." . self::COLOR_RESTORE
131+
);
129132
ModuleResolver::getInstance()->getAdminToken();
130-
$this->output->writeln('Successful');
133+
$this->output->writeln(self::COLOR_LIGHT_GREEN . 'Successful' . self::COLOR_RESTORE);
131134
$result = true;
132135
} catch (TestFrameworkException $e) {
133-
$this->output->writeln($e->getMessage());
136+
$this->output->writeln(self::COLOR_LIGHT_RED . $e->getMessage() . self::COLOR_RESTORE);
134137
}
135138
return $result;
136139
}
@@ -145,14 +148,14 @@ private function checkAuthenticationToMagentoAdmin()
145148
*/
146149
private function checkContextOnStep($exceptionType, $message)
147150
{
148-
$this->output->writeln("\n$message ...");
151+
$this->output->writeln("\n" . self::COLOR_LIGHT_DEFAULT. $message . self::COLOR_RESTORE);
149152
$this->runMagentoWebDriverDoctor();
150153

151154
if (isset($this->context[$exceptionType])) {
152-
$this->output->write($this->context[$exceptionType] . "\n");
155+
$this->output->writeln(self::COLOR_LIGHT_RED . $this->context[$exceptionType] . self::COLOR_RESTORE);
153156
return false;
154157
} else {
155-
$this->output->writeln('Successful');
158+
$this->output->writeln(self::COLOR_LIGHT_GREEN . 'Successful' . self::COLOR_RESTORE);
156159
return true;
157160
}
158161
}

0 commit comments

Comments
 (0)