diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 4fed54b7f..5b1d94057 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -96,6 +96,7 @@ class SchemaShell extends AppShell { $name = $plugin; } } + $name = Inflector::classify($name); $this->Schema = new CakeSchema(compact('name', 'path', 'file', 'connection', 'plugin')); } diff --git a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php index 3c3be73aa..d47f55691 100644 --- a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php @@ -498,6 +498,35 @@ class SchemaShellTest extends CakeTestCase { CakePlugin::unload(); } +/** + * test that underscored names also result in CamelCased class names + * + * @return void + */ + public function testName() { + 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', + 'force' => false, + 'overwrite' => true, + ); + $this->Shell->startup(); + if (file_exists($this->Shell->Schema->path . DS . 'custom_name.php')) { + unlink($this->Shell->Schema->path . DS . 'custom_name.php'); + } + $this->Shell->generate(); + + $contents = file_get_contents($this->Shell->Schema->path . DS . 'custom_name.php'); + $this->assertRegExp('/class CustomNameSchema/', $contents); + unlink($this->Shell->Schema->path . DS . 'custom_name.php'); + CakePlugin::unload(); + } + /** * test that using Plugin.name with write. *