Fixing issues with background colours, and adding tests for options.

This commit is contained in:
mark_story 2010-10-03 19:01:27 -04:00
parent d5b5fbee3b
commit 90d5c12b3e
2 changed files with 22 additions and 3 deletions

View file

@ -94,7 +94,7 @@ class ConsoleOutput {
*/ */
protected static $_options = array( protected static $_options = array(
'bold' => 1, 'bold' => 1,
'underscore' => 4, 'underline' => 4,
'blink' => 5, 'blink' => 5,
'reverse' => 7, 'reverse' => 7,
'conceal' => 8 'conceal' => 8
@ -164,8 +164,8 @@ class ConsoleOutput {
if (!empty($style['text']) && isset(self::$_foregroundColors[$style['text']])) { if (!empty($style['text']) && isset(self::$_foregroundColors[$style['text']])) {
$styleInfo[] = self::$_foregroundColors[$style['text']]; $styleInfo[] = self::$_foregroundColors[$style['text']];
} }
if (!empty($style['background']) && isset(self::$_foregroundColors[$style['background']])) { if (!empty($style['background']) && isset(self::$_backgroundColors[$style['background']])) {
$styleInfo[] = self::$_foregroundColors[$style['background']]; $styleInfo[] = self::$_backgroundColors[$style['background']];
} }
unset($style['text'], $style['background']); unset($style['text'], $style['background']);
foreach ($style as $option => $value) { foreach ($style as $option => $value) {

View file

@ -133,6 +133,25 @@ class ConsoleOutputTest extends CakeTestCase {
$this->output->write('<error>Error:</error> Something bad', false); $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. * test formatting text with missing styles.
* *