5
5
use PHP_Parallel_Lint \PhpConsoleColor \Test \Fixtures \ConsoleColorWithForceSupport ;
6
6
use PHPUnit \Framework \TestCase ;
7
7
8
+ /**
9
+ * @coversDefaultClass \PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor
10
+ * @covers ::__construct
11
+ */
8
12
class ConsoleColorTest extends TestCase
9
13
{
10
14
/** @var ConsoleColorWithForceSupport */
@@ -18,18 +22,28 @@ protected function setUpConsoleColor()
18
22
$ this ->uut = new ConsoleColorWithForceSupport ();
19
23
}
20
24
25
+ /**
26
+ * @covers ::apply
27
+ */
21
28
public function testNone ()
22
29
{
23
30
$ output = $ this ->uut ->apply ('none ' , 'text ' );
24
31
$ this ->assertSame ("text " , $ output );
25
32
}
26
33
34
+ /**
35
+ * @covers ::apply
36
+ * @covers ::escSequence
37
+ */
27
38
public function testBold ()
28
39
{
29
40
$ output = $ this ->uut ->apply ('bold ' , 'text ' );
30
41
$ this ->assertSame ("\033[1mtext \033[0m " , $ output );
31
42
}
32
43
44
+ /**
45
+ * @covers ::apply
46
+ */
33
47
public function testBoldColorsAreNotSupported ()
34
48
{
35
49
$ this ->uut ->setIsSupported (false );
@@ -38,6 +52,10 @@ public function testBoldColorsAreNotSupported()
38
52
$ this ->assertSame ("text " , $ output );
39
53
}
40
54
55
+ /**
56
+ * @covers ::apply
57
+ * @covers ::setForceStyle
58
+ */
41
59
public function testBoldColorsAreNotSupportedButAreForced ()
42
60
{
43
61
$ this ->uut ->setIsSupported (false );
@@ -47,24 +65,41 @@ public function testBoldColorsAreNotSupportedButAreForced()
47
65
$ this ->assertSame ("\033[1mtext \033[0m " , $ output );
48
66
}
49
67
68
+ /**
69
+ * @covers ::apply
70
+ * @covers ::escSequence
71
+ */
50
72
public function testDark ()
51
73
{
52
74
$ output = $ this ->uut ->apply ('dark ' , 'text ' );
53
75
$ this ->assertSame ("\033[2mtext \033[0m " , $ output );
54
76
}
55
77
78
+ /**
79
+ * @covers ::apply
80
+ * @covers ::escSequence
81
+ */
56
82
public function testBoldAndDark ()
57
83
{
58
84
$ output = $ this ->uut ->apply (array ('bold ' , 'dark ' ), 'text ' );
59
85
$ this ->assertSame ("\033[1;2mtext \033[0m " , $ output );
60
86
}
61
87
88
+ /**
89
+ * @covers ::apply
90
+ * @covers ::styleSequence
91
+ * @covers ::escSequence
92
+ */
62
93
public function test256ColorForeground ()
63
94
{
64
95
$ output = $ this ->uut ->apply ('color_255 ' , 'text ' );
65
96
$ this ->assertSame ("\033[38;5;255mtext \033[0m " , $ output );
66
97
}
67
98
99
+ /**
100
+ * @covers ::apply
101
+ * @covers ::styleSequence
102
+ */
68
103
public function test256ColorWithoutSupport ()
69
104
{
70
105
$ this ->uut ->setAre256ColorsSupported (false );
@@ -73,32 +108,55 @@ public function test256ColorWithoutSupport()
73
108
$ this ->assertSame ("text " , $ output );
74
109
}
75
110
111
+ /**
112
+ * @covers ::apply
113
+ * @covers ::styleSequence
114
+ * @covers ::escSequence
115
+ */
76
116
public function test256ColorBackground ()
77
117
{
78
118
$ output = $ this ->uut ->apply ('bg_color_255 ' , 'text ' );
79
119
$ this ->assertSame ("\033[48;5;255mtext \033[0m " , $ output );
80
120
}
81
121
122
+ /**
123
+ * @covers ::apply
124
+ * @covers ::styleSequence
125
+ * @covers ::escSequence
126
+ */
82
127
public function test256ColorForegroundAndBackground ()
83
128
{
84
129
$ output = $ this ->uut ->apply (array ('color_200 ' , 'bg_color_255 ' ), 'text ' );
85
130
$ this ->assertSame ("\033[38;5;200;48;5;255mtext \033[0m " , $ output );
86
131
}
87
132
133
+ /**
134
+ * @covers ::setThemes
135
+ * @covers ::themeSequence
136
+ */
88
137
public function testSetOwnTheme ()
89
138
{
90
139
$ this ->uut ->setThemes (array ('bold_dark ' => array ('bold ' , 'dark ' )));
91
140
$ output = $ this ->uut ->apply (array ('bold_dark ' ), 'text ' );
92
141
$ this ->assertSame ("\033[1;2mtext \033[0m " , $ output );
93
142
}
94
143
144
+ /**
145
+ * @covers ::addTheme
146
+ * @covers ::themeSequence
147
+ */
95
148
public function testAddOwnTheme ()
96
149
{
97
150
$ this ->uut ->addTheme ('bold_own ' , 'bold ' );
98
151
$ output = $ this ->uut ->apply (array ('bold_own ' ), 'text ' );
99
152
$ this ->assertSame ("\033[1mtext \033[0m " , $ output );
100
153
}
101
154
155
+ /**
156
+ * @covers ::apply
157
+ * @covers ::addTheme
158
+ * @covers ::themeSequence
159
+ */
102
160
public function testAddOwnThemeArray ()
103
161
{
104
162
$ this ->uut ->addTheme ('bold_dark ' , array ('bold ' , 'dark ' ));
@@ -116,6 +174,13 @@ public function testAddOwnThemeInvalidInput()
116
174
$ this ->uut ->addTheme ('invalid ' , new \ArrayIterator (array ('bold ' , 'dark ' )));
117
175
}
118
176
177
+ /**
178
+ * @covers ::apply
179
+ * @covers ::addTheme
180
+ * @covers ::themeSequence
181
+ * @covers ::styleSequence
182
+ * @covers ::isValidStyle
183
+ */
119
184
public function testOwnWithStyle ()
120
185
{
121
186
$ this ->uut ->addTheme ('bold_dark ' , array ('bold ' , 'dark ' ));
@@ -145,6 +210,10 @@ public function testGetThemes()
145
210
$ this ->assertCount (2 , $ themes );
146
211
}
147
212
213
+ /**
214
+ * @covers ::hasTheme
215
+ * @covers ::removeTheme
216
+ */
148
217
public function testHasAndRemoveTheme ()
149
218
{
150
219
$ this ->assertFalse ($ this ->uut ->hasTheme ('bold_dark ' ));
@@ -156,37 +225,60 @@ public function testHasAndRemoveTheme()
156
225
$ this ->assertFalse ($ this ->uut ->hasTheme ('bold_dark ' ));
157
226
}
158
227
228
+ /**
229
+ * @covers ::apply
230
+ */
159
231
public function testApplyInvalidArgument ()
160
232
{
161
233
$ this ->exceptionHelper ('\InvalidArgumentException ' );
162
234
$ this ->uut ->apply (new \stdClass (), 'text ' );
163
235
}
164
236
237
+ /**
238
+ * @covers ::apply
239
+ * @covers \PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException
240
+ */
165
241
public function testApplyInvalidStyleName ()
166
242
{
167
243
$ this ->exceptionHelper ('\PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException ' );
168
244
$ this ->uut ->apply ('invalid ' , 'text ' );
169
245
}
170
246
247
+ /**
248
+ * @covers ::apply
249
+ * @covers \PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException
250
+ */
171
251
public function testApplyInvalid256Color ()
172
252
{
173
253
$ this ->exceptionHelper ('\PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException ' );
174
254
$ this ->uut ->apply ('color_2134 ' , 'text ' );
175
255
}
176
256
257
+ /**
258
+ * @covers ::addTheme
259
+ * @covers ::isValidStyle
260
+ * @covers \PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException
261
+ */
177
262
public function testThemeInvalidStyle ()
178
263
{
179
264
$ this ->exceptionHelper ('\PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException ' );
180
265
$ this ->uut ->addTheme ('invalid ' , array ('invalid ' ));
181
266
}
182
267
268
+ /**
269
+ * @covers ::setForceStyle
270
+ * @covers ::isStyleForced
271
+ */
183
272
public function testForceStyle ()
184
273
{
185
274
$ this ->assertFalse ($ this ->uut ->isStyleForced ());
186
275
$ this ->uut ->setForceStyle (true );
187
276
$ this ->assertTrue ($ this ->uut ->isStyleForced ());
188
277
}
189
278
279
+ /**
280
+ * @covers ::getPossibleStyles
281
+ */
190
282
public function testGetPossibleStyles ()
191
283
{
192
284
if (\method_exists ($ this , 'assertIsArray ' )) {
0 commit comments