Skip to content

Commit

Permalink
asserting that under_scored names result in valid ClassNames
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Aug 8, 2012
1 parent bed5453 commit 5190b9f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/Cake/Console/Command/SchemaShell.php
Expand Up @@ -96,6 +96,7 @@ public function startup() {
$name = $plugin;
}
}
$name = Inflector::classify($name);
$this->Schema = new CakeSchema(compact('name', 'path', 'file', 'connection', 'plugin'));
}

Expand Down
29 changes: 29 additions & 0 deletions lib/Cake/Test/Case/Console/Command/SchemaShellTest.php
Expand Up @@ -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.
*
Expand Down

0 comments on commit 5190b9f

Please sign in to comment.