Permalink
Browse files

Fixing help not getting called

Adding tests
  • Loading branch information...
1 parent 1d8f57d commit 06d3aee348ac3bdcccb6d4f6fc735c6c1e811e2b @davidpersson davidpersson committed May 2, 2009
Showing with 25 additions and 1 deletion.
  1. +1 −1 cake/console/cake.php
  2. +24 −0 cake/tests/cases/console/cake.test.php
View
2 cake/console/cake.php
@@ -344,7 +344,7 @@ function dispatch() {
}
return $Shell->{$task}->execute();
}
- $methods = get_class_methods('Shell');
+ $methods = array_diff(get_class_methods('Shell'), array('help'));
}
$methods = array_diff(get_class_methods($Shell), $methods);
$added = in_array(strtolower($arg), array_map('strtolower', $methods));
View
24 cake/tests/cases/console/cake.test.php
@@ -516,6 +516,17 @@ function testDispatchShellWithMain() {
$Shell = new MockWithMainShell();
$Shell->setReturnValue('main', true);
+ $Shell->expectOnce('startup');
+ $Shell->expectOnce('help');
+ $Dispatcher->TestShell =& $Shell;
+
+ $Dispatcher->args = array('mock_with_main', 'help');
+ $result = $Dispatcher->dispatch();
+ $this->assertNull($result);
+ $this->assertEqual($Dispatcher->args, array());
+
+ $Shell = new MockWithMainShell();
+ $Shell->setReturnValue('main', true);
$Shell->expectNever('hr');
$Shell->expectOnce('startup');
$Shell->expectOnce('main');
@@ -811,6 +822,19 @@ function testDispatchTask() {
$result = $Dispatcher->dispatch();
$this->assertTrue($result);
$this->assertEqual($Dispatcher->args, array());
+
+ $Shell = new MockWeekShell();
+ $Task = new MockOnSundayTask();
+ $Task->expectNever('execute');
+ $Task->expectOnce('help');
+
+ $Shell->MockOnSunday =& $Task;
+ $Shell->taskNames = array('MockOnSunday');
+ $Dispatcher->TestShell =& $Shell;
+
+ $Dispatcher->args = array('mock_week', 'mock_on_sunday', 'help');
+ $result = $Dispatcher->dispatch();
+ $this->assertTrue($result);
}
/**
* Verify shifting of arguments

0 comments on commit 06d3aee

Please sign in to comment.