diff --git a/cake/console/libs/tasks/model.php b/cake/console/libs/tasks/model.php index 97d28eb6a60..30ebe6fd2d0 100644 --- a/cake/console/libs/tasks/model.php +++ b/cake/console/libs/tasks/model.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); diff --git a/cake/tests/cases/console/libs/tasks/model.test.php b/cake/tests/cases/console/libs/tasks/model.test.php index 157dc1c7861..967c04bfbb3 100644 --- a/cake/tests/cases/console/libs/tasks/model.test.php +++ b/cake/tests/cases/console/libs/tasks/model.test.php @@ -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. *