File tree Expand file tree Collapse file tree 1 file changed +34
-2
lines changed
src/TextUI/Command/Commands Expand file tree Collapse file tree 1 file changed +34
-2
lines changed Original file line number Diff line number Diff line change 16
16
use function sprintf ;
17
17
use function strlen ;
18
18
use PHPUnit \Runner \Version ;
19
+ use PHPUnit \Util \Color ;
20
+ use SebastianBergmann \Environment \Console ;
19
21
20
22
/**
21
23
* @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit
64
66
'requiredExtensions ' => [],
65
67
],
66
68
];
69
+ private bool $ colorize ;
70
+
71
+ public function __construct ()
72
+ {
73
+ $ this ->colorize = (new Console )->hasColorSupport ();
74
+ }
67
75
68
76
public function execute (): Result
69
77
{
@@ -78,9 +86,9 @@ public function execute(): Result
78
86
}
79
87
80
88
if (ini_get ($ name ) === $ setting ['expectedValue ' ]) {
81
- $ check = ' ok ' ;
89
+ $ check = $ this -> ok () ;
82
90
} else {
83
- $ check = ' not ok ' ;
91
+ $ check = $ this -> notOk () ;
84
92
$ shellExitCode = 1 ;
85
93
}
86
94
@@ -115,4 +123,28 @@ public function execute(): Result
115
123
116
124
return Result::from ($ buffer , $ shellExitCode );
117
125
}
126
+
127
+ /**
128
+ * @return non-empty-string
129
+ */
130
+ private function ok (): string
131
+ {
132
+ if (!$ this ->colorize ) {
133
+ return 'ok ' ;
134
+ }
135
+
136
+ return Color::colorizeTextBox ('fg-green, bold ' , 'ok ' );
137
+ }
138
+
139
+ /**
140
+ * @return non-empty-string
141
+ */
142
+ private function notOk (): string
143
+ {
144
+ if (!$ this ->colorize ) {
145
+ return 'not ok ' ;
146
+ }
147
+
148
+ return Color::colorizeTextBox ('fg-red, bold ' , 'not ok ' );
149
+ }
118
150
}
You can’t perform that action at this time.
0 commit comments