asserting that under_scored names result in valid ClassNames

This commit is contained in:
euromark 2012-08-08 16:35:59 +02:00
parent bed5453be0
commit 5190b9f2c9
2 changed files with 30 additions and 0 deletions

View file

@ -96,6 +96,7 @@ class SchemaShell extends AppShell {
$name = $plugin;
}
}
$name = Inflector::classify($name);
$this->Schema = new CakeSchema(compact('name', 'path', 'file', 'connection', 'plugin'));
}

View file

@ -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.
*