From 5190b9f2c91f5ac2adf36ce529c1be53ff89e8f2 Mon Sep 17 00:00:00 2001 From: euromark Date: Wed, 8 Aug 2012 16:35:59 +0200 Subject: [PATCH] asserting that under_scored names result in valid ClassNames --- lib/Cake/Console/Command/SchemaShell.php | 1 + .../Case/Console/Command/SchemaShellTest.php | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 4fed54b7fa9..5b1d94057d6 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -96,6 +96,7 @@ public function startup() { $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 3c3be73aacb..d47f5569177 100644 --- a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php @@ -498,6 +498,35 @@ public function testPluginParam() { 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. *