Skip to content

Commit

Permalink
Adding test coverage for inOptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 10, 2009
1 parent d066a4a commit 6be70c3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cake/tests/cases/console/libs/tasks/model.test.php
Expand Up @@ -460,5 +460,25 @@ function testConfirmAssociations() {
$this->assertTrue(empty($result['hasMany']));
$this->assertTrue(empty($result['hasOne']));
}

/**
* test that inOptions generates questions and only accepts a valid answer
*
* @return void
**/
function testInOptions() {
$options = array('one', 'two', 'three');
$this->Task->expectAt(0, 'out', array('1. one'));
$this->Task->expectAt(1, 'out', array('2. two'));
$this->Task->expectAt(2, 'out', array('3. three'));
$this->Task->setReturnValueAt(0, 'in', 10);

$this->Task->expectAt(3, 'out', array('1. one'));
$this->Task->expectAt(4, 'out', array('2. two'));
$this->Task->expectAt(5, 'out', array('3. three'));
$this->Task->setReturnValueAt(1, 'in', 2);
$result = $this->Task->inOptions($options, 'Pick a number');
$this->assertEqual($result, 1);
}
}
?>

0 comments on commit 6be70c3

Please sign in to comment.