Skip to content

Commit

Permalink
Make schema import plugin friendly.
Browse files Browse the repository at this point in the history
The changes in #8694 pointed out that schema importing doesn't play nice
with plugins. This corrects that.
  • Loading branch information
markstory committed Apr 23, 2016
1 parent 3a75e8a commit 9536a10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Cake/Console/Command/Task/FixtureTask.php
Expand Up @@ -178,9 +178,13 @@ protected function _interactive() {
*/
public function importOptions($modelName) {
$options = array();
$plugin = '';
if (isset($this->params['plugin'])) {
$plugin = $this->params['plugin'] . '.';
}

if (!empty($this->params['schema'])) {
$options['schema'] = $modelName;
$options['schema'] = $plugin . $modelName;
} elseif ($this->interactive) {
$doSchema = $this->in(__d('cake_console', 'Would you like to import schema for this fixture?'), array('y', 'n'), 'n');
if ($doSchema === 'y') {
Expand Down
13 changes: 13 additions & 0 deletions lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php
Expand Up @@ -136,6 +136,19 @@ public function testImportOptionsWithCommandLineOptions() {
$this->assertEquals($expected, $result);
}

/**
* test importOptions with overwriting CLI options
*
* @return void
*/
public function testImportOptionsWithCommandLineOptionsPlugin() {
$this->Task->params = array('schema' => true, 'records' => true, 'plugin' => 'TestPlugin');

$result = $this->Task->importOptions('Article');
$expected = array('schema' => 'TestPlugin.Article', 'fromTable' => true);
$this->assertEquals($expected, $result);
}

/**
* test importOptions with schema.
*
Expand Down

0 comments on commit 9536a10

Please sign in to comment.