Skip to content

Commit fdddebb

Browse files
committed
Tests: add @covers tag
... to document what each test is testing.
1 parent 3a8ed08 commit fdddebb

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed

tests/ConsoleColorTest.php

+92
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
use PHP_Parallel_Lint\PhpConsoleColor\Test\Fixtures\ConsoleColorWithForceSupport;
66
use PHPUnit\Framework\TestCase;
77

8+
/**
9+
* @coversDefaultClass \PHP_Parallel_Lint\PhpConsoleColor\ConsoleColor
10+
* @covers ::__construct
11+
*/
812
class ConsoleColorTest extends TestCase
913
{
1014
/** @var ConsoleColorWithForceSupport */
@@ -18,18 +22,28 @@ protected function setUpConsoleColor()
1822
$this->uut = new ConsoleColorWithForceSupport();
1923
}
2024

25+
/**
26+
* @covers ::apply
27+
*/
2128
public function testNone()
2229
{
2330
$output = $this->uut->apply('none', 'text');
2431
$this->assertSame("text", $output);
2532
}
2633

34+
/**
35+
* @covers ::apply
36+
* @covers ::escSequence
37+
*/
2738
public function testBold()
2839
{
2940
$output = $this->uut->apply('bold', 'text');
3041
$this->assertSame("\033[1mtext\033[0m", $output);
3142
}
3243

44+
/**
45+
* @covers ::apply
46+
*/
3347
public function testBoldColorsAreNotSupported()
3448
{
3549
$this->uut->setIsSupported(false);
@@ -38,6 +52,10 @@ public function testBoldColorsAreNotSupported()
3852
$this->assertSame("text", $output);
3953
}
4054

55+
/**
56+
* @covers ::apply
57+
* @covers ::setForceStyle
58+
*/
4159
public function testBoldColorsAreNotSupportedButAreForced()
4260
{
4361
$this->uut->setIsSupported(false);
@@ -47,24 +65,41 @@ public function testBoldColorsAreNotSupportedButAreForced()
4765
$this->assertSame("\033[1mtext\033[0m", $output);
4866
}
4967

68+
/**
69+
* @covers ::apply
70+
* @covers ::escSequence
71+
*/
5072
public function testDark()
5173
{
5274
$output = $this->uut->apply('dark', 'text');
5375
$this->assertSame("\033[2mtext\033[0m", $output);
5476
}
5577

78+
/**
79+
* @covers ::apply
80+
* @covers ::escSequence
81+
*/
5682
public function testBoldAndDark()
5783
{
5884
$output = $this->uut->apply(array('bold', 'dark'), 'text');
5985
$this->assertSame("\033[1;2mtext\033[0m", $output);
6086
}
6187

88+
/**
89+
* @covers ::apply
90+
* @covers ::styleSequence
91+
* @covers ::escSequence
92+
*/
6293
public function test256ColorForeground()
6394
{
6495
$output = $this->uut->apply('color_255', 'text');
6596
$this->assertSame("\033[38;5;255mtext\033[0m", $output);
6697
}
6798

99+
/**
100+
* @covers ::apply
101+
* @covers ::styleSequence
102+
*/
68103
public function test256ColorWithoutSupport()
69104
{
70105
$this->uut->setAre256ColorsSupported(false);
@@ -73,32 +108,55 @@ public function test256ColorWithoutSupport()
73108
$this->assertSame("text", $output);
74109
}
75110

111+
/**
112+
* @covers ::apply
113+
* @covers ::styleSequence
114+
* @covers ::escSequence
115+
*/
76116
public function test256ColorBackground()
77117
{
78118
$output = $this->uut->apply('bg_color_255', 'text');
79119
$this->assertSame("\033[48;5;255mtext\033[0m", $output);
80120
}
81121

122+
/**
123+
* @covers ::apply
124+
* @covers ::styleSequence
125+
* @covers ::escSequence
126+
*/
82127
public function test256ColorForegroundAndBackground()
83128
{
84129
$output = $this->uut->apply(array('color_200', 'bg_color_255'), 'text');
85130
$this->assertSame("\033[38;5;200;48;5;255mtext\033[0m", $output);
86131
}
87132

133+
/**
134+
* @covers ::setThemes
135+
* @covers ::themeSequence
136+
*/
88137
public function testSetOwnTheme()
89138
{
90139
$this->uut->setThemes(array('bold_dark' => array('bold', 'dark')));
91140
$output = $this->uut->apply(array('bold_dark'), 'text');
92141
$this->assertSame("\033[1;2mtext\033[0m", $output);
93142
}
94143

144+
/**
145+
* @covers ::addTheme
146+
* @covers ::themeSequence
147+
*/
95148
public function testAddOwnTheme()
96149
{
97150
$this->uut->addTheme('bold_own', 'bold');
98151
$output = $this->uut->apply(array('bold_own'), 'text');
99152
$this->assertSame("\033[1mtext\033[0m", $output);
100153
}
101154

155+
/**
156+
* @covers ::apply
157+
* @covers ::addTheme
158+
* @covers ::themeSequence
159+
*/
102160
public function testAddOwnThemeArray()
103161
{
104162
$this->uut->addTheme('bold_dark', array('bold', 'dark'));
@@ -116,6 +174,13 @@ public function testAddOwnThemeInvalidInput()
116174
$this->uut->addTheme('invalid', new \ArrayIterator(array('bold', 'dark')));
117175
}
118176

177+
/**
178+
* @covers ::apply
179+
* @covers ::addTheme
180+
* @covers ::themeSequence
181+
* @covers ::styleSequence
182+
* @covers ::isValidStyle
183+
*/
119184
public function testOwnWithStyle()
120185
{
121186
$this->uut->addTheme('bold_dark', array('bold', 'dark'));
@@ -145,6 +210,10 @@ public function testGetThemes()
145210
$this->assertCount(2, $themes);
146211
}
147212

213+
/**
214+
* @covers ::hasTheme
215+
* @covers ::removeTheme
216+
*/
148217
public function testHasAndRemoveTheme()
149218
{
150219
$this->assertFalse($this->uut->hasTheme('bold_dark'));
@@ -156,37 +225,60 @@ public function testHasAndRemoveTheme()
156225
$this->assertFalse($this->uut->hasTheme('bold_dark'));
157226
}
158227

228+
/**
229+
* @covers ::apply
230+
*/
159231
public function testApplyInvalidArgument()
160232
{
161233
$this->exceptionHelper('\InvalidArgumentException');
162234
$this->uut->apply(new \stdClass(), 'text');
163235
}
164236

237+
/**
238+
* @covers ::apply
239+
* @covers \PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException
240+
*/
165241
public function testApplyInvalidStyleName()
166242
{
167243
$this->exceptionHelper('\PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException');
168244
$this->uut->apply('invalid', 'text');
169245
}
170246

247+
/**
248+
* @covers ::apply
249+
* @covers \PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException
250+
*/
171251
public function testApplyInvalid256Color()
172252
{
173253
$this->exceptionHelper('\PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException');
174254
$this->uut->apply('color_2134', 'text');
175255
}
176256

257+
/**
258+
* @covers ::addTheme
259+
* @covers ::isValidStyle
260+
* @covers \PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException
261+
*/
177262
public function testThemeInvalidStyle()
178263
{
179264
$this->exceptionHelper('\PHP_Parallel_Lint\PhpConsoleColor\InvalidStyleException');
180265
$this->uut->addTheme('invalid', array('invalid'));
181266
}
182267

268+
/**
269+
* @covers ::setForceStyle
270+
* @covers ::isStyleForced
271+
*/
183272
public function testForceStyle()
184273
{
185274
$this->assertFalse($this->uut->isStyleForced());
186275
$this->uut->setForceStyle(true);
187276
$this->assertTrue($this->uut->isStyleForced());
188277
}
189278

279+
/**
280+
* @covers ::getPossibleStyles
281+
*/
190282
public function testGetPossibleStyles()
191283
{
192284
if (\method_exists($this, 'assertIsArray')) {

0 commit comments

Comments
 (0)