Skip to content

Commit

Permalink
Fixing issues with background colours, and adding tests for options.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 14, 2010
1 parent d5b5fbe commit 90d5c12
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cake/console/console_output.php
Expand Up @@ -94,7 +94,7 @@ class ConsoleOutput {
*/
protected static $_options = array(
'bold' => 1,
'underscore' => 4,
'underline' => 4,
'blink' => 5,
'reverse' => 7,
'conceal' => 8
Expand Down Expand Up @@ -164,8 +164,8 @@ protected function _replaceTags($matches) {
if (!empty($style['text']) && isset(self::$_foregroundColors[$style['text']])) {
$styleInfo[] = self::$_foregroundColors[$style['text']];
}
if (!empty($style['background']) && isset(self::$_foregroundColors[$style['background']])) {
$styleInfo[] = self::$_foregroundColors[$style['background']];
if (!empty($style['background']) && isset(self::$_backgroundColors[$style['background']])) {
$styleInfo[] = self::$_backgroundColors[$style['background']];
}
unset($style['text'], $style['background']);
foreach ($style as $option => $value) {
Expand Down
19 changes: 19 additions & 0 deletions cake/tests/cases/console/console_output.test.php
Expand Up @@ -133,6 +133,25 @@ function testFormattingSimple() {
$this->output->write('<error>Error:</error> Something bad', false);
}

/**
* test formatting with custom styles.
*
* @return void
*/
function testFormattingCustom() {
$this->output->styles('annoying', array(
'text' => 'magenta',
'background' => 'cyan',
'blink' => true,
'underline' => true
));

$this->output->expects($this->once())->method('_write')
->with("\033[35;46;5;4mAnnoy:\033[0m Something bad");

$this->output->write('<annoying>Annoy:</annoying> Something bad', false);
}

/**
* test formatting text with missing styles.
*
Expand Down

0 comments on commit 90d5c12

Please sign in to comment.