Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix Shell::nl() to be outputting newlines instead of returning. #721

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+32 −12
Split
@@ -580,14 +580,14 @@ public function err($message = null, $newlines = 1) {
}
/**
- * Returns a single or multiple linefeeds sequences.
+ * Outputs a single or multiple linefeeds sequences to the standard output.
*
* @param integer $multiplier Number of times the linefeed sequence should be repeated
- * @return string
+ * @return void
* @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::nl
*/
public function nl($multiplier = 1) {
- return str_repeat(ConsoleOutput::LF, $multiplier);
+ $this->out(null, $multiplier);
}
/**
@@ -378,15 +378,35 @@ public function testErr() {
* @return void
*/
public function testNl() {
- $newLine = "\n";
- if (DS === '\\') {
- $newLine = "\r\n";
- }
- $this->assertEquals($this->Shell->nl(), $newLine);
- $this->assertEquals($this->Shell->nl(true), $newLine);
- $this->assertEquals("", $this->Shell->nl(false));
- $this->assertEquals($this->Shell->nl(2), $newLine . $newLine);
- $this->assertEquals($this->Shell->nl(1), $newLine);
+ $this->Shell->stdout->expects($this->at(0))
+ ->method('write')
+ ->with('', 1);
+
+ $this->Shell->stdout->expects($this->at(1))
+ ->method('write')
+ ->with('', 2);
+
+ $this->Shell->stdout->expects($this->at(2))
+ ->method('write')
+ ->with('', 1);
+
+ $this->Shell->stdout->expects($this->at(3))
+ ->method('write')
+ ->with('', true);
+
+ $this->Shell->stdout->expects($this->at(4))
+ ->method('write')
+ ->with('', false);
+
+ $this->Shell->nl();
+
+ $this->Shell->nl(2);
+
+ $this->Shell->nl(1);
+
+ $this->Shell->nl(true);
+
+ $this->Shell->nl(false);
}
/**