Skip to content

Commit

Permalink
Merge pull request #153 from cakephp/fixture-list
Browse files Browse the repository at this point in the history
Fixtures generation is now using filtered table
  • Loading branch information
lorenzo committed Aug 20, 2015
2 parents 087004c + 0fce343 commit 2d4e87a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 17 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
4 changes: 2 additions & 2 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
2 changes: 1 addition & 1 deletion 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
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 2d4e87a

Please sign in to comment.