Skip to content

Commit

Permalink
Adding skipTables to ModelTask. Allows skipping of predefined tables.…
Browse files Browse the repository at this point in the history
… Adding i18n table to the default list of skipped tables. Fixes #327
  • Loading branch information
markstory committed Feb 13, 2010
1 parent b89f40b commit 3f667eb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cake/console/libs/tasks/model.php
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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);
Expand Down
30 changes: 30 additions & 0 deletions cake/tests/cases/console/libs/tasks/model.test.php
Expand Up @@ -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.
*
Expand Down

0 comments on commit 3f667eb

Please sign in to comment.