Make schema import plugin friendly.

The changes in #8694 pointed out that schema importing doesn't play nice
with plugins. This corrects that.
This commit is contained in:
mark_story 2016-04-23 16:18:15 -04:00
parent 3a75e8aa72
commit 9536a10d6d
2 changed files with 18 additions and 1 deletions

View file

@ -178,9 +178,13 @@ class FixtureTask extends BakeTask {
*/
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') {

View file

@ -136,6 +136,19 @@ class FixtureTaskTest extends CakeTestCase {
$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.
*