Skip to content

Commit

Permalink
Adding fixture all command.
Browse files Browse the repository at this point in the history
Fixing errors with maxlength and timestamp fields
Adding return for ModelTask::listAll()
  • Loading branch information
markstory committed Apr 30, 2009
1 parent d3fe3d5 commit 40ebdf8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
12 changes: 11 additions & 1 deletion cake/console/libs/tasks/fixture.php
Expand Up @@ -91,6 +91,12 @@ function all() {
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);
}
}

/**
Expand Down Expand Up @@ -246,10 +252,14 @@ function _generateRecords($tableInfo, $recordCount = 1) {
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'";
Expand Down
1 change: 1 addition & 0 deletions cake/console/libs/tasks/model.php
Expand Up @@ -770,6 +770,7 @@ function listAll($useDbConfig = 'default', $interactive = true) {
$this->out($i + 1 . ". " . $this->_modelNames[$i]);
}
}
return $this->__tables;
}
/**
* Interact with the user to determine the table name of a particular model
Expand Down
6 changes: 5 additions & 1 deletion cake/tests/cases/console/libs/tasks/model.test.php
Expand Up @@ -74,6 +74,7 @@ function startTest() {
$this->Task =& new MockModelTask($this->Dispatcher);
$this->Task->Dispatch = new $this->Dispatcher;
}

/**
* tearDown method
*
Expand All @@ -84,6 +85,7 @@ function endTest() {
unset($this->Task, $this->Dispatcher);
ClassRegistry::flush();
}

/**
* Test that listAll scans the database connection and lists all the tables in it.s
*
Expand All @@ -93,7 +95,9 @@ function testListAll() {
$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);
}

/**
Expand Down

0 comments on commit 40ebdf8

Please sign in to comment.