Adding fixture all command.

Fixing errors with maxlength and timestamp fields
Adding return for ModelTask::listAll()
This commit is contained in:
mark_story 2009-04-29 22:50:43 -04:00
parent d3fe3d5959
commit 40ebdf8aac
3 changed files with 17 additions and 2 deletions

View file

@ -91,6 +91,12 @@ class FixtureTask extends Shell {
if (isset($this->params['connection'])) {
$ds = $this->params['connection'];
}
$this->interactive = false;
$tables = $this->Model->listAll($ds, false);
foreach ($tables as $table) {
$model = $this->_modelName($table);
$this->bake($model);
}
}
/**
@ -246,10 +252,14 @@ class FixtureTask extends Shell {
case 'string';
$insert = "Lorem ipsum dolor sit amet";
if (!empty($fieldInfo['length'])) {
$insert = substr($insert, 0, (int)$value['length'] - 2);
$insert = substr($insert, 0, (int)$fieldInfo['length'] - 2);
}
$insert = "'$insert'";
break;
case 'timestamp':
$ts = time();
$insert = "'$ts'";
break;
case 'datetime':
$ts = date('Y-m-d H:i:s');
$insert = "'$ts'";

View file

@ -770,6 +770,7 @@ class ModelTask extends Shell {
$this->out($i + 1 . ". " . $this->_modelNames[$i]);
}
}
return $this->__tables;
}
/**
* Interact with the user to determine the table name of a particular model

View file

@ -74,6 +74,7 @@ class ModelTaskTest extends CakeTestCase {
$this->Task =& new MockModelTask($this->Dispatcher);
$this->Task->Dispatch = new $this->Dispatcher;
}
/**
* tearDown method
*
@ -84,6 +85,7 @@ class ModelTaskTest extends CakeTestCase {
unset($this->Task, $this->Dispatcher);
ClassRegistry::flush();
}
/**
* Test that listAll scans the database connection and lists all the tables in it.s
*
@ -93,7 +95,9 @@ class ModelTaskTest extends CakeTestCase {
$this->Task->expectCallCount('out', 3);
$this->Task->expectAt(1, 'out', array('1. Article'));
$this->Task->expectAt(2, 'out', array('2. Comment'));
$this->Task->listAll('test_suite');
$result = $this->Task->listAll('test_suite');
$expected = array('articles', 'comments');
$this->assertEqual($result, $expected);
}
/**