From 40ebdf8aac62eab983c22f3d001c547d24e8bbee Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 29 Apr 2009 22:50:43 -0400 Subject: [PATCH] Adding fixture all command. Fixing errors with maxlength and timestamp fields Adding return for ModelTask::listAll() --- cake/console/libs/tasks/fixture.php | 12 +++++++++++- cake/console/libs/tasks/model.php | 1 + cake/tests/cases/console/libs/tasks/model.test.php | 6 +++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cake/console/libs/tasks/fixture.php b/cake/console/libs/tasks/fixture.php index fa307a7f7..a9f5b8054 100644 --- a/cake/console/libs/tasks/fixture.php +++ b/cake/console/libs/tasks/fixture.php @@ -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'"; diff --git a/cake/console/libs/tasks/model.php b/cake/console/libs/tasks/model.php index df5021749..bcb38a01a 100644 --- a/cake/console/libs/tasks/model.php +++ b/cake/console/libs/tasks/model.php @@ -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 diff --git a/cake/tests/cases/console/libs/tasks/model.test.php b/cake/tests/cases/console/libs/tasks/model.test.php index 5f6a35e01..954c5f2ad 100644 --- a/cake/tests/cases/console/libs/tasks/model.test.php +++ b/cake/tests/cases/console/libs/tasks/model.test.php @@ -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); } /**