mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Merge pull request #1716 from ricog/schema-name-and-file
SchemaShell: Prevent name param from overwriting file param if both are passed Fixes #4134.
This commit is contained in:
commit
bc92b1e600
2 changed files with 37 additions and 1 deletions
|
@ -67,7 +67,7 @@ class SchemaShell extends AppShell {
|
||||||
$name = $this->params['name'] = $splitName;
|
$name = $this->params['name'] = $splitName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name) {
|
if ($name && empty($this->params['file'])) {
|
||||||
$this->params['file'] = Inflector::underscore($name);
|
$this->params['file'] = Inflector::underscore($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -585,6 +585,42 @@ class SchemaShellTest extends CakeTestCase {
|
||||||
CakePlugin::unload();
|
CakePlugin::unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that passing name and file creates the passed filename with the
|
||||||
|
* passed classname
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testNameAndFile() {
|
||||||
|
App::build(array(
|
||||||
|
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
|
||||||
|
));
|
||||||
|
CakePlugin::load('TestPlugin');
|
||||||
|
$this->Shell->params = array(
|
||||||
|
'plugin' => 'TestPlugin',
|
||||||
|
'connection' => 'test',
|
||||||
|
'name' => 'custom_name',
|
||||||
|
'file' => 'other_name',
|
||||||
|
'force' => false,
|
||||||
|
'overwrite' => true,
|
||||||
|
);
|
||||||
|
$this->Shell->startup();
|
||||||
|
$file = $this->Shell->Schema->path . DS . 'other_name.php';
|
||||||
|
if (file_exists($file)) {
|
||||||
|
unlink($file);
|
||||||
|
}
|
||||||
|
$this->Shell->generate();
|
||||||
|
|
||||||
|
$this->assertFileExists($file);
|
||||||
|
$contents = file_get_contents($file);
|
||||||
|
$this->assertRegExp('/class CustomNameSchema/', $contents);
|
||||||
|
|
||||||
|
if (file_exists($file)) {
|
||||||
|
unlink($file);
|
||||||
|
}
|
||||||
|
CakePlugin::unload();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test that using Plugin.name with write.
|
* test that using Plugin.name with write.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue