From 7921ef1282f3e26b954346d2643b7565d29e7401 Mon Sep 17 00:00:00 2001 From: mark_story Date: Tue, 5 Oct 2010 22:44:47 -0400 Subject: [PATCH] Fixing Shell tests to use ConsoleInput. --- cake/console/libs/shell.php | 7 ++++ cake/tests/cases/console/libs/shell.test.php | 38 +++++++++----------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/cake/console/libs/shell.php b/cake/console/libs/shell.php index fbf026981..d0fd9022d 100644 --- a/cake/console/libs/shell.php +++ b/cake/console/libs/shell.php @@ -155,6 +155,13 @@ class Shell extends Object { */ public $stderr; +/** + * stdin object + * + * @var ConsoleInput + */ + public $stdin; + /** * Constructs this Shell instance. * diff --git a/cake/tests/cases/console/libs/shell.test.php b/cake/tests/cases/console/libs/shell.test.php index a82b8694b..6f12c46fb 100644 --- a/cake/tests/cases/console/libs/shell.test.php +++ b/cake/tests/cases/console/libs/shell.test.php @@ -110,7 +110,8 @@ class ShellTest extends CakeTestCase { ); $output = $this->getMock('ConsoleOutput'); $error = $this->getMock('ConsoleOutput'); - $this->Shell =& new TestShell($this->Dispatcher, $output, $error); + $in = $this->getMock('ConsoleInput'); + $this->Shell =& new TestShell($this->Dispatcher, $output, $error, $in); } /** @@ -174,29 +175,24 @@ class ShellTest extends CakeTestCase { * @return void */ public function testIn() { - $this->Dispatcher->expects($this->at(0)) - ->method('getInput') - ->with('Just a test?', array('y', 'n'), 'n') + $this->Shell->stdin->expects($this->at(0)) + ->method('read') ->will($this->returnValue('n')); - $this->Dispatcher->expects($this->at(1)) - ->method('getInput') - ->with('Just a test?', array('y', 'n'), 'n') + $this->Shell->stdin->expects($this->at(1)) + ->method('read') ->will($this->returnValue('Y')); - $this->Dispatcher->expects($this->at(2)) - ->method('getInput') - ->with('Just a test?', 'y,n', 'n') + $this->Shell->stdin->expects($this->at(2)) + ->method('read') ->will($this->returnValue('y')); - $this->Dispatcher->expects($this->at(3)) - ->method('getInput') - ->with('Just a test?', 'y/n', 'n') + $this->Shell->stdin->expects($this->at(3)) + ->method('read') ->will($this->returnValue('y')); - $this->Dispatcher->expects($this->at(4)) - ->method('getInput') - ->with('Just a test?', 'y', 'y') + $this->Shell->stdin->expects($this->at(4)) + ->method('read') ->will($this->returnValue('y')); $result = $this->Shell->in('Just a test?', array('y', 'n'), 'n'); @@ -471,14 +467,12 @@ class ShellTest extends CakeTestCase { $this->Shell->interactive = true; - $this->Shell->Dispatch->expects($this->at(5)) - ->method('getInput') - ->withAnyParameters() + $this->Shell->stdin->expects($this->at(0)) + ->method('read') ->will($this->returnValue('n')); - $this->Shell->Dispatch->expects($this->at(9)) - ->method('getInput') - ->withAnyParameters() + $this->Shell->stdin->expects($this->at(1)) + ->method('read') ->will($this->returnValue('y'));