Skip to content

Commit

Permalink
Merge branch 'master' into 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
antograssiot committed Aug 20, 2015
2 parents ebe3fd5 + 2d4e87a commit 6f12119
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
8 changes: 2 additions & 6 deletions src/Shell/BakeShell.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public function all($name = null)
if (empty($name) && !$this->param('everything')) {
$this->Model->connection = $this->connection;
$this->out('Possible model names based on your database:');
foreach ($this->Model->listAll() as $table) {
foreach ($this->Model->listUnskipped() as $table) {
$this->out('- ' . $table);
}
$this->out('Run <info>`cake bake all [name]`</info> to generate skeleton files.');
Expand All @@ -237,11 +237,7 @@ public function all($name = null)

if ($this->param('everything')) {
$this->Model->connection = $this->connection;
$allTables = collection($this->Model->listAll());
$filteredTables = $allTables->reject(function ($tableName) {
$ignoredTables = ['i18n', 'cake_sessions', 'phinxlog', 'users_phinxlog'];
return in_array($tableName, $ignoredTables);
});
$filteredTables = collection($this->Model->listUnskipped());
}

$filteredTables->each(function ($tableName) {
Expand Down
4 changes: 2 additions & 2 deletions src/Shell/Task/FixtureTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function main($name = null)

if (empty($name)) {
$this->out('Choose a fixture to bake from the following:');
foreach ($this->Model->listAll() as $table) {
foreach ($this->Model->listUnskipped() as $table) {
$this->out('- ' . $this->_camelize($table));
}
return true;
Expand All @@ -130,7 +130,7 @@ public function main($name = null)
*/
public function all()
{
$tables = $this->Model->listAll($this->connection, false);
$tables = $this->Model->listUnskipped($this->connection, false);

foreach ($tables as $table) {
$this->main($table);
Expand Down
6 changes: 3 additions & 3 deletions src/Shell/Task/ModelTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ModelTask extends BakeTask
*
* @var array
*/
public $skipTables = ['i18n', 'phinxlog'];
public $skipTables = ['i18n', 'cake_sessions', 'phinxlog', 'users_phinxlog'];

/**
* Holds tables found on connection.
Expand Down Expand Up @@ -87,7 +87,7 @@ public function main($name = null)

if (empty($name)) {
$this->out('Choose a model to bake from the following:');
foreach ($this->listAll() as $table) {
foreach ($this->listUnskipped() as $table) {
$this->out('- ' . $this->_camelize($table));
}
return true;
Expand Down Expand Up @@ -131,7 +131,7 @@ public function bake($name)
);
$this->bakeTable($model, $data);
$this->bakeEntity($model, $data);
$this->bakeFixture($model->alias(), $table);
$this->bakeFixture($model->alias(), $model->table());
$this->bakeTest($model->alias());
}

Expand Down
14 changes: 8 additions & 6 deletions src/Shell/Task/TemplateTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function main($name = null, $template = null, $action = null)
if (empty($name)) {
$this->out('Possible tables to bake views for based on your current database:');
$this->Model->connection = $this->connection;
foreach ($this->Model->listAll() as $table) {
foreach ($this->Model->listUnskipped() as $table) {
$this->out('- ' . $this->_camelize($table));
}
return true;
Expand Down Expand Up @@ -257,6 +257,7 @@ public function all()
* Loads Controller and sets variables for the template
* Available template variables:
*
* - 'modelObject'
* - 'modelClass'
* - 'primaryKey'
* - 'displayField'
Expand All @@ -272,16 +273,16 @@ public function all()
*/
protected function _loadController()
{
$modelObj = TableRegistry::get($this->modelName);
$modelObject = TableRegistry::get($this->modelName);

$primaryKey = (array)$modelObj->primaryKey();
$displayField = $modelObj->displayField();
$primaryKey = (array)$modelObject->primaryKey();
$displayField = $modelObject->displayField();
$singularVar = $this->_singularName($this->controllerName);
$singularHumanName = $this->_singularHumanName($this->controllerName);
$schema = $modelObj->schema();
$schema = $modelObject->schema();
$fields = $schema->columns();
$modelClass = $this->modelName;
$associations = $this->_filteredAssociations($modelObj);
$associations = $this->_filteredAssociations($modelObject);
$keyFields = [];
if (!empty($associations['BelongsTo'])) {
foreach ($associations['BelongsTo'] as $assoc) {
Expand All @@ -293,6 +294,7 @@ protected function _loadController()
$pluralHumanName = $this->_pluralHumanName($this->controllerName);

return compact(
'modelObject',
'modelClass',
'schema',
'primaryKey',
Expand Down
10 changes: 5 additions & 5 deletions tests/TestCase/Shell/Task/FixtureTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function setUp()
);
$this->Task->Model = $this->getMock(
'Bake\Shell\Task\ModelTask',
['in', 'out', 'err', 'createFile', 'getName', 'getTable', 'listAll'],
['in', 'out', 'err', 'createFile', 'getName', 'getTable', 'listUnskipped'],
[$io]
);
$this->Task->BakeTemplate = new BakeTemplateTask($io);
Expand Down Expand Up @@ -207,7 +207,7 @@ public function testMainIntoAll()
{
$this->Task->connection = 'test';
$this->Task->Model->expects($this->any())
->method('listAll')
->method('listUnskipped')
->will($this->returnValue(['articles', 'comments']));

$filename = $this->_normalizePath(ROOT . DS . 'tests' . DS . 'Fixture/ArticlesFixture.php');
Expand All @@ -233,7 +233,7 @@ public function testAllWithCountAndRecordsFlags()
$this->Task->connection = 'test';
$this->Task->params = ['count' => 10, 'records' => true];

$this->Task->Model->expects($this->any())->method('listAll')
$this->Task->Model->expects($this->any())->method('listUnskipped')
->will($this->returnValue(['Articles', 'comments']));

$filename = $this->_normalizePath(ROOT . DS . 'tests' . DS . 'Fixture/ArticlesFixture.php');
Expand Down Expand Up @@ -261,7 +261,7 @@ public function testAllWithSchemaImport()
$this->Task->connection = 'test';
$this->Task->params = ['schema' => true];

$this->Task->Model->expects($this->any())->method('listAll')
$this->Task->Model->expects($this->any())->method('listUnskipped')
->will($this->returnValue(['Articles', 'comments']));

$filename = $this->_normalizePath(ROOT . DS . 'tests' . DS . 'Fixture/ArticlesFixture.php');
Expand All @@ -286,7 +286,7 @@ public function testMainNoArgs()
$this->Task->connection = 'test';

$this->Task->Model->expects($this->any())
->method('listAll')
->method('listUnskipped')
->will($this->returnValue(['articles', 'comments']));

$filename = $this->_normalizePath(ROOT . '/tests/Fixture/ArticlesFixture.php');
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Shell/Task/TemplateTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ public function testMainNoArgs()
$this->_setupTask(['in', 'err', 'bake', 'createFile', '_stop']);

$this->Task->Model->expects($this->once())
->method('listAll')
->method('listUnskipped')
->will($this->returnValue(['comments', 'articles']));

$this->Task->expects($this->never())
Expand Down

0 comments on commit 6f12119

Please sign in to comment.