Skip to content
Permalink
Browse files

Adding return from _stop() to help testing.

Updating tests for getName()
  • Loading branch information...
markstory committed May 27, 2010
1 parent 9647e35 commit 8ac46c3b6392d6d9ac81b7ea00c39dbef9faa170
Showing with 21 additions and 17 deletions.
  1. +1 −2 cake/console/libs/tasks/controller.php
  2. +20 −15 cake/tests/cases/console/libs/tasks/controller.test.php
@@ -409,10 +409,9 @@ public function getName($useDbConfig = null) {
while ($enteredController == '') {
$enteredController = $this->in(__("Enter a number from the list above,\ntype in the name of another controller, or 'q' to exit"), null, 'q');
if ($enteredController === 'q') {
$this->out(__('Exit'));
$this->_stop();
return $this->_stop();
}
if ($enteredController == '' || intval($enteredController) > count($controllers)) {
@@ -139,27 +139,32 @@ public function testListAll() {
*
* @return void
*/
public function xxtestGetName() {
public function testGetNameValidIndex() {
$this->Task->interactive = true;
$this->Task->expects($this->any())->method('in')->will($this->returnValue(1));
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('q'));
$this->Task->expectOnce('_stop');
$this->Task->getName('test_suite');
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(1));
$this->Task->expects($this->at(5))->method('in')->will($this->returnValue(3));
$result = $this->Task->getName('test_suite');
$expected = 'Articles';
$expected = 'Comments';
$this->assertEqual($result, $expected);
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue(3));
$this->Task->expects($this->at(7))->method('in')->will($this->returnValue(1));
$result = $this->Task->getName('test_suite');
$expected = 'Comments';
$expected = 'Articles';
$this->assertEqual($result, $expected);
}
$this->Task->expects($this->at(3))->method('in')->will($this->returnValue(10));
$result = $this->Task->getName('test_suite');
$this->Task->expectOnce('err');
/**
* test getting invalid indexes.
*
* @return void
*/
function testGetNameInvalidIndex() {
$this->Task->interactive = true;
$this->Task->expects($this->at(5))->method('in')->will($this->returnValue(10));
$this->Task->expects($this->at(7))->method('in')->will($this->returnValue('q'));
$this->Task->expects($this->once())->method('err');
$this->Task->expects($this->once())->method('_stop');
$this->Task->getName('test_suite');
}
/**

0 comments on commit 8ac46c3

Please sign in to comment.
You can’t perform that action at this time.