Permalink
Browse files

Adding test coverage for inOptions.

  • Loading branch information...
1 parent d066a4a commit 6be70c3cfa7ab5bfa9a9e66f2d230f7fec4e280e @markstory markstory committed May 10, 2009
Showing with 20 additions and 0 deletions.
  1. +20 −0 cake/tests/cases/console/libs/tasks/model.test.php
@@ -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.