Adding return from _stop() to help testing.

Updating tests for getName()
This commit is contained in:
mark_story 2010-05-26 21:59:56 -04:00
parent 9647e359c4
commit 8ac46c3b63
2 changed files with 22 additions and 18 deletions

View file

@ -409,10 +409,9 @@ class ControllerTask extends BakeTask {
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)) {

View file

@ -139,27 +139,32 @@ class ControllerTaskTest extends CakeTestCase {
*
* @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));
$result = $this->Task->getName('test_suite');
$expected = 'Articles';
$this->assertEqual($result, $expected);
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue(3));
$this->Task->expects($this->at(5))->method('in')->will($this->returnValue(3));
$result = $this->Task->getName('test_suite');
$expected = 'Comments';
$this->assertEqual($result, $expected);
$this->Task->expects($this->at(3))->method('in')->will($this->returnValue(10));
$this->Task->expects($this->at(7))->method('in')->will($this->returnValue(1));
$result = $this->Task->getName('test_suite');
$this->Task->expectOnce('err');
$expected = 'Articles';
$this->assertEqual($result, $expected);
}
/**
* 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');
}
/**