mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
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:
parent
3a75e8aa72
commit
9536a10d6d
2 changed files with 18 additions and 1 deletions
|
@ -178,9 +178,13 @@ class FixtureTask extends BakeTask {
|
||||||
*/
|
*/
|
||||||
public function importOptions($modelName) {
|
public function importOptions($modelName) {
|
||||||
$options = array();
|
$options = array();
|
||||||
|
$plugin = '';
|
||||||
|
if (isset($this->params['plugin'])) {
|
||||||
|
$plugin = $this->params['plugin'] . '.';
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($this->params['schema'])) {
|
if (!empty($this->params['schema'])) {
|
||||||
$options['schema'] = $modelName;
|
$options['schema'] = $plugin . $modelName;
|
||||||
} elseif ($this->interactive) {
|
} elseif ($this->interactive) {
|
||||||
$doSchema = $this->in(__d('cake_console', 'Would you like to import schema for this fixture?'), array('y', 'n'), 'n');
|
$doSchema = $this->in(__d('cake_console', 'Would you like to import schema for this fixture?'), array('y', 'n'), 'n');
|
||||||
if ($doSchema === 'y') {
|
if ($doSchema === 'y') {
|
||||||
|
|
|
@ -136,6 +136,19 @@ class FixtureTaskTest extends CakeTestCase {
|
||||||
$this->assertEquals($expected, $result);
|
$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.
|
* test importOptions with schema.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue