Navigation Menu

Skip to content

Commit

Permalink
Adding prompt for supplying custom conditions for fixture.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jul 20, 2009
1 parent de51d88 commit 10f5ae2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
17 changes: 15 additions & 2 deletions cake/console/libs/tasks/fixture.php
Expand Up @@ -52,6 +52,12 @@ class FixtureTask extends Shell {
* @var string
**/
var $connection = null;
/**
* Schema instance
*
* @var object
**/
var $_Schema = null;
/**
* Override initialize
*
Expand Down Expand Up @@ -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;
}
/**
Expand Down
8 changes: 8 additions & 0 deletions cake/tests/cases/console/libs/tasks/fixture.test.php
Expand Up @@ -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.
Expand Down

0 comments on commit 10f5ae2

Please sign in to comment.