Skip to content
Permalink
Browse files

Adding newline param to Shell::err

The signature of ::err is now identical to ::out
Adding tests for ::err
  • Loading branch information...
mariuswilms committed Apr 16, 2009
1 parent 73cbdf0 commit 4faa9d3b21de78c4d637673014894423d64e67f0
Showing with 16 additions and 2 deletions.
  1. +3 −2 cake/console/libs/shell.php
  2. +13 −0 cake/tests/cases/console/libs/shell.test.php
@@ -358,17 +358,18 @@ function out($string, $newline = true) {
* Outputs to the stderr filehandle.
*
* @param string $string Error text to output.
* @param boolean $newline If true, the outputs gets an added newline.
* @access public
*/
function err($string) {
function err($string, $newline = true) {
if (is_array($string)) {
$str = '';
foreach ($string as $message) {
$str .= $message ."\n";
}
$string = $str;
}
return $this->Dispatch->stderr($string."\n");
return $this->Dispatch->stderr($string . ($newline ? "\n" : ''));
}
/**
* Outputs a series of minus characters to the standard output, acts as a visual separator.
@@ -160,6 +160,19 @@ function testOut() {
$this->Shell->Dispatch->expectAt(1, 'stdout', array("Just\na\ntest\n", true));
$this->Shell->out(array('Just', 'a', 'test'));
}
/**
* testErr method
*
* @return void
* @access public
*/
function testErr() {
$this->Shell->Dispatch->expectAt(0, 'stderr', array("Just a test\n"));
$this->Shell->err('Just a test');
$this->Shell->Dispatch->expectAt(1, 'stderr', array("Just\na\ntest\n\n"));
$this->Shell->err(array('Just', 'a', 'test'));
}
/**
* testIn method
*

0 comments on commit 4faa9d3

Please sign in to comment.
You can’t perform that action at this time.