Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding newline param to Shell::err

The signature of ::err is now identical to ::out
Adding tests for ::err
  • Loading branch information...
commit 4faa9d3b21de78c4d637673014894423d64e67f0 1 parent 73cbdf0
David Persson davidpersson authored
5 cake/console/libs/shell.php
View
@@ -358,9 +358,10 @@ 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) {
@@ -368,7 +369,7 @@ function err($string) {
}
$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.
13 cake/tests/cases/console/libs/shell.test.php
View
@@ -161,6 +161,19 @@ function testOut() {
$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
*
* @return void
Please sign in to comment.
Something went wrong with that request. Please try again.