Skip to content
Permalink
Browse files

Adding prompt for supplying custom conditions for fixture.

  • Loading branch information...
markstory committed Jul 20, 2009
1 parent de51d88 commit 10f5ae22a9821898681309dd85571123b428b6b4
Showing with 23 additions and 2 deletions.
  1. +15 −2 cake/console/libs/tasks/fixture.php
  2. +8 −0 cake/tests/cases/console/libs/tasks/fixture.test.php
@@ -52,6 +52,12 @@ class FixtureTask extends Shell {
* @var string
**/
var $connection = null;
/**
* Schema instance
*
* @var object
**/
var $_Schema = null;
/**
* Override initialize
*
@@ -128,14 +134,21 @@ function __interactive() {
**/
function importOptions($modelName) {
$options = array();
$doSchema = $this->in('Would you like to import schema for this fixture?', array('y', 'n'), 'n');
$doSchema = $this->in(__('Would you like to import schema for this fixture?', true), array('y', 'n'), 'n');
if ($doSchema == 'y') {
$options['schema'] = $modelName;
}
$doRecords = $this->in('Would you like to import records for this fixture?', array('y', 'n'), 'n');
$doRecords = $this->in(__('Would you like to use record importing for this fixture?', true), array('y', 'n'), 'n');
if ($doRecords == 'y') {
$options['records'] = true;
}
if ($doRecords == 'n') {
$prompt = sprintf(__("Would you like to build this fixture with data from %s's table?", true), $modelName);
$fromDb = $this->in($prompt, array('y', 'n'), 'n');
if (strtolower($fromDb) == 'y') {
$options['fromTable'] = true;
}
}
return $options;
}
/**
@@ -112,10 +112,18 @@ function testImportOptions() {
$this->Task->setReturnValueAt(2, 'in', 'n');
$this->Task->setReturnValueAt(3, 'in', 'n');
$this->Task->setReturnValueAt(4, 'in', 'n');
$result = $this->Task->importOptions('Article');
$expected = array();
$this->assertEqual($result, $expected);
$this->Task->setReturnValueAt(5, 'in', 'n');
$this->Task->setReturnValueAt(6, 'in', 'n');
$this->Task->setReturnValueAt(7, 'in', 'y');
$result = $this->Task->importOptions('Article');
$expected = array('fromTable' => true);
$this->assertEqual($result, $expected);
}
/**
* test that execute passes runs bake depending with named model.

0 comments on commit 10f5ae2

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