Skip to content

Commit c5fb346

Browse files
Merge pull request #116 from wp-cli/colors
Fix reverse (inverse) and white (grey).
2 parents c5f9c03 + 65b5ac2 commit c5fb346

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

lib/cli/Colors.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static public function getColors() {
231231
'%p' => array('color' => 'magenta'),
232232
'%m' => array('color' => 'magenta'),
233233
'%c' => array('color' => 'cyan'),
234-
'%w' => array('color' => 'grey'),
234+
'%w' => array('color' => 'white'),
235235
'%k' => array('color' => 'black'),
236236
'%n' => array('color' => 'reset'),
237237
'%Y' => array('color' => 'yellow', 'style' => 'bright'),
@@ -241,7 +241,7 @@ static public function getColors() {
241241
'%P' => array('color' => 'magenta', 'style' => 'bright'),
242242
'%M' => array('color' => 'magenta', 'style' => 'bright'),
243243
'%C' => array('color' => 'cyan', 'style' => 'bright'),
244-
'%W' => array('color' => 'grey', 'style' => 'bright'),
244+
'%W' => array('color' => 'white', 'style' => 'bright'),
245245
'%K' => array('color' => 'black', 'style' => 'bright'),
246246
'%N' => array('color' => 'reset', 'style' => 'bright'),
247247
'%3' => array('background' => 'yellow'),
@@ -250,11 +250,11 @@ static public function getColors() {
250250
'%1' => array('background' => 'red'),
251251
'%5' => array('background' => 'magenta'),
252252
'%6' => array('background' => 'cyan'),
253-
'%7' => array('background' => 'grey'),
253+
'%7' => array('background' => 'white'),
254254
'%0' => array('background' => 'black'),
255255
'%F' => array('style' => 'blink'),
256256
'%U' => array('style' => 'underline'),
257-
'%8' => array('style' => 'inverse'),
257+
'%8' => array('style' => 'reverse'),
258258
'%9' => array('style' => 'bright'),
259259
'%_' => array('style' => 'bright')
260260
);

tests/test-colors.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
use cli\Colors;
4+
5+
class testsColors extends PHPUnit_Framework_TestCase {
6+
7+
/**
8+
* @dataProvider dataColors
9+
*/
10+
function testColors( $str, $color ) {
11+
$colored = Colors::color( $color );
12+
$this->assertSame( Colors::colorize( $str ), Colors::color( $color ) );
13+
if ( in_array( 'reset', $color ) ) {
14+
$this->assertTrue( false !== strpos( $colored, '[0m' ) );
15+
} else {
16+
$this->assertTrue( false === strpos( $colored, '[0m' ) );
17+
}
18+
}
19+
20+
function dataColors() {
21+
$ret = array();
22+
foreach ( Colors::getColors() as $str => $color ) {
23+
$ret[] = array( $str, $color );
24+
}
25+
return $ret;
26+
}
27+
}

0 commit comments

Comments
 (0)