Skip to content

Commit

Permalink
Add missing ConsoleIo method.
Browse files Browse the repository at this point in the history
When updating the documentation, I noticed that styles() was missing on
ConsoleIo. This corrects that issue.
  • Loading branch information
markstory committed Apr 28, 2014
1 parent 61759ad commit eef1145
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
15 changes: 15 additions & 0 deletions src/Console/ConsoleIo.php
Expand Up @@ -240,11 +240,26 @@ public function ask($prompt, $default = null) {
*
* @param int $mode
* @return void
* @see \Cake\Console\ConsoleOutput::outputAs()
*/
public function outputAs($mode) {
$this->_out->outputAs($mode);
}

/**
* Add a new output style or get defined styles.
*
* @param string $style The style to get or create.
* @param array $definition The array definition of the style to change or create a style
* or false to remove a style.
* @return mixed If you are getting styles, the style or null will be returned. If you are creating/modifying
* styles true will be returned.
* @see \Cake\Console\ConsoleOutput::styles()
*/
public function styles($style = null, $definition = null) {
$this->_out->styles($style, $definition);
}

/**
* Prompts the user for input based on a list of options, and returns it.
*
Expand Down
6 changes: 3 additions & 3 deletions src/Console/ConsoleOutput.php
Expand Up @@ -241,15 +241,15 @@ protected function _write($message) {
*
* ### Get a style definition
*
* `$this->output->styles('error');`
* `$output->styles('error');`
*
* ### Get all the style definitions
*
* `$this->output->styles();`
* `$output->styles();`
*
* ### Create or modify an existing style
*
* `$this->output->styles('annoy', ['text' => 'purple', 'background' => 'yellow', 'blink' => true]);`
* `$output->styles('annoy', ['text' => 'purple', 'background' => 'yellow', 'blink' => true]);`
*
* ### Remove a style
*
Expand Down
12 changes: 12 additions & 0 deletions tests/TestCase/Console/ConsoleIoTest.php
Expand Up @@ -327,4 +327,16 @@ public function testSetLoggers() {
$this->assertFalse(Log::engine('stderr'));
}

/**
* Ensure that styles() just proxies to stdout.
*
* @return void
*/
public function testStyles() {
$this->out->expects($this->once())
->method('styles')
->with('name', 'props');
$this->io->styles('name', 'props');
}

}

0 comments on commit eef1145

Please sign in to comment.