Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding test coverage for inOptions.

  • Loading branch information...
commit 6be70c3cfa7ab5bfa9a9e66f2d230f7fec4e280e 1 parent d066a4a
@markstory markstory authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 cake/tests/cases/console/libs/tasks/model.test.php
View
20 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);
+ }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.