Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/Cake/Console/Shell.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -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 * @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 * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::nl
*/ */
public function nl($multiplier = 1) { public function nl($multiplier = 1) {
return str_repeat(ConsoleOutput::LF, $multiplier); $this->out(null, $multiplier);
} }


/** /**
Expand Down
38 changes: 29 additions & 9 deletions lib/Cake/Test/Case/Console/ShellTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -378,15 +378,35 @@ public function testErr() {
* @return void * @return void
*/ */
public function testNl() { public function testNl() {
$newLine = "\n"; $this->Shell->stdout->expects($this->at(0))
if (DS === '\\') { ->method('write')
$newLine = "\r\n"; ->with('', 1);
}
$this->assertEquals($this->Shell->nl(), $newLine); $this->Shell->stdout->expects($this->at(1))
$this->assertEquals($this->Shell->nl(true), $newLine); ->method('write')
$this->assertEquals("", $this->Shell->nl(false)); ->with('', 2);
$this->assertEquals($this->Shell->nl(2), $newLine . $newLine);
$this->assertEquals($this->Shell->nl(1), $newLine); $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);
} }


/** /**
Expand Down