Skip to content

Commit 5190b9f

Browse files
author
euromark
committed
asserting that under_scored names result in valid ClassNames
1 parent bed5453 commit 5190b9f

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/Cake/Console/Command/SchemaShell.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ public function startup() {
9696
$name = $plugin;
9797
}
9898
}
99+
$name = Inflector::classify($name);
99100
$this->Schema = new CakeSchema(compact('name', 'path', 'file', 'connection', 'plugin'));
100101
}
101102

lib/Cake/Test/Case/Console/Command/SchemaShellTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,35 @@ public function testPluginParam() {
498498
CakePlugin::unload();
499499
}
500500

501+
/**
502+
* test that underscored names also result in CamelCased class names
503+
*
504+
* @return void
505+
*/
506+
public function testName() {
507+
App::build(array(
508+
'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)
509+
));
510+
CakePlugin::load('TestPlugin');
511+
$this->Shell->params = array(
512+
'plugin' => 'TestPlugin',
513+
'connection' => 'test',
514+
'name' => 'custom_name',
515+
'force' => false,
516+
'overwrite' => true,
517+
);
518+
$this->Shell->startup();
519+
if (file_exists($this->Shell->Schema->path . DS . 'custom_name.php')) {
520+
unlink($this->Shell->Schema->path . DS . 'custom_name.php');
521+
}
522+
$this->Shell->generate();
523+
524+
$contents = file_get_contents($this->Shell->Schema->path . DS . 'custom_name.php');
525+
$this->assertRegExp('/class CustomNameSchema/', $contents);
526+
unlink($this->Shell->Schema->path . DS . 'custom_name.php');
527+
CakePlugin::unload();
528+
}
529+
501530
/**
502531
* test that using Plugin.name with write.
503532
*

0 commit comments

Comments
 (0)