Skip to content
Permalink
Browse files

Adding skipTables to ModelTask. Allows skipping of predefined tables.…

… Adding i18n table to the default list of skipped tables. Fixes #327
  • Loading branch information...
markstory committed Feb 13, 2010
1 parent b89f40b commit 3f667eb4122369e45c5f0f1f6eb28702cb21e7b8
Showing with 41 additions and 0 deletions.
  1. +11 −0 cake/console/libs/tasks/model.php
  2. +30 −0 cake/tests/cases/console/libs/tasks/model.test.php
@@ -58,6 +58,14 @@ class ModelTask extends Shell {
*/
var $tasks = array('DbConfig', 'Fixture', 'Test', 'Template');
/**
* Tables to skip when running all()
*
* @var array
* @access protected
*/
var $skipTables = array('i18n');
/**
* Holds tables found on connection.
*
@@ -114,6 +122,9 @@ function all() {
$this->listAll($this->connection, false);
$unitTestExists = $this->_checkUnitTest();
foreach ($this->_tables as $table) {
if (in_array($table, $this->skipTables)) {
continue;
}
$modelClass = Inflector::classify($table);
$this->out(sprintf(__('Baking %s', true), $modelClass));
$object = $this->_getModelObject($modelClass);
@@ -743,6 +743,36 @@ function testExecuteIntoAll() {
$this->assertEqual(count(ClassRegistry::mapKeys()), 0);
}
/**
* test that skipTables changes how all() works.
*
* @return void
*/
function testSkipTablesAndAll() {
$this->Task->connection = 'test_suite';
$this->Task->path = '/my/path/';
$this->Task->args = array('all');
$this->Task->setReturnValue('_checkUnitTest', true);
$this->Task->skipTables = array('tags');
$this->Task->Fixture->expectCallCount('bake', 4);
$this->Task->Test->expectCallCount('bake', 4);
$filename = '/my/path/article.php';
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class Article/')));
$filename = '/my/path/articles_tag.php';
$this->Task->expectAt(1, 'createFile', array($filename, new PatternExpectation('/class ArticlesTag/')));
$filename = '/my/path/category_thread.php';
$this->Task->expectAt(2, 'createFile', array($filename, new PatternExpectation('/class CategoryThread/')));
$filename = '/my/path/comment.php';
$this->Task->expectAt(3, 'createFile', array($filename, new PatternExpectation('/class Comment/')));
$this->Task->execute();
}
/**
* test the interactive side of bake.
*

0 comments on commit 3f667eb

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