diff --git a/cake/tests/cases/console/libs/shell.test.php b/cake/tests/cases/console/libs/shell.test.php index fd91aa5e9..45a25075a 100644 --- a/cake/tests/cases/console/libs/shell.test.php +++ b/cake/tests/cases/console/libs/shell.test.php @@ -602,4 +602,55 @@ class ShellTest extends CakeTestCase { $this->assertFalse($this->Shell->hasMethod('_secret'), '_secret is callable'); $this->assertFalse($this->Shell->hasMethod('no_access'), 'no_access is callable'); } + +/** + * test run command calling main. + * + * @return void + */ + function testRunCommandMain() { + $methods = get_class_methods('Shell'); + $Mock = $this->getMock('Shell', array('main', 'startup'), array(), '', false); + + $Mock->expects($this->once())->method('main')->will($this->returnValue(true)); + $Mock->expects($this->once())->method('startup'); + $result = $Mock->runCommand(null, array()); + $this->assertTrue($result); + } + +/** + * test run command causing exception on Shell method. + * + * @expectedException RuntimeException + * @return void + */ + function testRunCommandBaseclassMethod() { + $methods = get_class_methods('Shell'); + $Mock = $this->getMock('Shell', array('startup'), array(), '', false); + + $Mock->expects($this->once())->method('startup'); + $Mock->expects($this->never())->method('hr'); + $result = $Mock->runCommand('hr', array()); + } + +/** + * test that a --help causes help to show. + * + * @return void + */ + function testHelpParamTriggeringHelp() { + $Parser = $this->getMock('ConsoleOptionParser', array(), array(), '', false); + $Parser->expects($this->once())->method('parse') + ->with(array('--help')) + ->will($this->returnValue(array(array('help' => true), array()))); + $Parser->expects($this->once())->method('help'); + + $Shell = $this->getMock('Shell', array('_getOptionParser', 'out', 'startup'), array(), '', false); + $Shell->expects($this->once())->method('_getOptionParser') + ->will($this->returnValue($Parser)); + $Shell->expects($this->once())->method('out'); + $Shell->expects($this->once())->method('startup'); + + $Shell->runCommand(null, array('--help')); + } } diff --git a/cake/tests/cases/console/shell_dispatcher.test.php b/cake/tests/cases/console/shell_dispatcher.test.php index 20cd34be4..4ae1f3f74 100644 --- a/cake/tests/cases/console/shell_dispatcher.test.php +++ b/cake/tests/cases/console/shell_dispatcher.test.php @@ -230,7 +230,6 @@ class ShellDispatcherTest extends CakeTestCase { ); $expected = array( 'app' => 'new', - 'dry' => true, 'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'new'), 'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH), 'webroot' => 'webroot' @@ -256,15 +255,14 @@ class ShellDispatcherTest extends CakeTestCase { 'webroot' => 'webroot', 'working' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH . DS . 'app'), 'root' => str_replace('\\', '/', CAKE_CORE_INCLUDE_PATH), - 'dry' => true, - 'f' => true, - 'name' => 'DbAcl' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); - $expected = array('./console/cake.php', 'schema', 'run', 'create'); + $expected = array( + './console/cake.php', 'schema', 'run', 'create', '-dry', '-f', '-name', 'DbAcl' + ); $this->assertEqual($expected, $Dispatcher->args); $params = array( @@ -283,15 +281,11 @@ class ShellDispatcherTest extends CakeTestCase { 'webroot' => 'webroot', 'working' => '/cake/1.2.x.x/app', 'root' => '/cake/1.2.x.x', - 'dry' => true, - 'name' => 'DbAcl' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params); $this->assertEqual($expected, $Dispatcher->params); - $expected = array('/cake/1.2.x.x/cake/console/cake.php', 'schema', 'run', 'create'); - $this->assertEqual($expected, $Dispatcher->args); $params = array( 'cake.php', '-working', @@ -344,7 +338,6 @@ class ShellDispatcherTest extends CakeTestCase { 'webroot' => 'webroot', 'working' => 'C:\wamp\www\apps\cake\app', 'root' => 'C:\wamp\www\apps\cake', - 'url' => 'http://example.com/some/url/with/a/path' ); $Dispatcher->params = $Dispatcher->args = array(); $Dispatcher->parseParams($params);