18
18
use Magento \FunctionalTestingFramework \Util \ModuleResolver ;
19
19
use Magento \FunctionalTestingFramework \Module \MagentoWebDriver ;
20
20
use Magento \FunctionalTestingFramework \Module \MagentoWebDriverDoctor ;
21
+ use Symfony \Component \Console \Style \SymfonyStyle ;
21
22
22
23
class DoctorCommand extends Command
23
24
{
@@ -30,11 +31,11 @@ class DoctorCommand extends Command
30
31
const COLOR_RESTORE = "\e[0m " ;
31
32
32
33
/**
33
- * Command Output
34
+ * Input and output SymfonyStyle
34
35
*
35
- * @var OutputInterface
36
+ * @var SymfonyStyle
36
37
*/
37
- private $ output ;
38
+ private $ ioStyle ;
38
39
39
40
/**
40
41
* Exception Context
@@ -63,11 +64,12 @@ protected function configure()
63
64
* @param OutputInterface $output
64
65
* @return integer
65
66
* @throws TestFrameworkException
66
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
67
67
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
68
68
*/
69
69
protected function execute (InputInterface $ input , OutputInterface $ output )
70
70
{
71
+ $ this ->ioStyle = new SymfonyStyle ($ input , $ output );
72
+
71
73
$ cmdStatus = true ;
72
74
73
75
// Config application
@@ -126,14 +128,13 @@ private function checkAuthenticationToMagentoAdmin()
126
128
{
127
129
$ result = false ;
128
130
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 ... " );
132
133
ModuleResolver::getInstance ()->getAdminToken ();
133
- $ this ->output -> writeln ( self :: COLOR_LIGHT_GREEN . 'Successful ' . self :: COLOR_RESTORE );
134
+ $ this ->ioStyle -> success ( 'Successful ' );
134
135
$ result = true ;
135
136
} catch (TestFrameworkException $ e ) {
136
- $ this ->output -> writeln ( self :: COLOR_LIGHT_RED . $ e ->getMessage () . self :: COLOR_RESTORE );
137
+ $ this ->ioStyle -> error ( $ e ->getMessage ());
137
138
}
138
139
return $ result ;
139
140
}
@@ -148,14 +149,15 @@ private function checkAuthenticationToMagentoAdmin()
148
149
*/
149
150
private function checkContextOnStep ($ exceptionType , $ message )
150
151
{
151
- $ this ->output ->writeln ("\n" . self ::COLOR_LIGHT_DEFAULT . $ message . self ::COLOR_RESTORE );
152
+ $ this ->ioStyle ->newLine ();
153
+ $ this ->ioStyle ->section ($ message );
152
154
$ this ->runMagentoWebDriverDoctor ();
153
155
154
156
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 ]);
156
158
return false ;
157
159
} else {
158
- $ this ->output -> writeln ( self :: COLOR_LIGHT_GREEN . 'Successful ' . self :: COLOR_RESTORE );
160
+ $ this ->ioStyle -> success ( 'Successful ' );
159
161
return true ;
160
162
}
161
163
}
0 commit comments