Skip to content

Commit

Permalink
Merge pull request #296 from cakephp/issue-294
Browse files Browse the repository at this point in the history
An empty database should create an empty dump file
  • Loading branch information
lorenzo authored Jan 7, 2017
2 parents 7d3dcad + f95cd93 commit f2a5e29
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions src/Command/Dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
$tables = $this->getTablesToBake($collection, $options);

$dump = [];
if (empty($tables)) {
$this->output()->writeln('<info>No tables were found : the dump file was not created</info>');
return false;
}

foreach ($tables as $table) {
$schema = $collection->describe($table);
$dump[$table] = $schema;
if ($tables) {
foreach ($tables as $table) {
$schema = $collection->describe($table);
$dump[$table] = $schema;
}
}

$filePath = $path . DS . 'schema-dump-' . $connectionName . '.lock';
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Command/DumpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public function testExecuteNoTables()
'--source' => 'TestsMigrations'
]);

$display = $commandTester->getDisplay();
$this->assertTextContains('No tables were found : the dump file was not created', $display);
$dumpPath = ROOT . 'config' . DS . 'TestsMigrations' . DS . 'schema-dump-test.lock';
$this->assertEquals(serialize([]), file_get_contents($dumpPath));
}

/**
Expand Down

0 comments on commit f2a5e29

Please sign in to comment.