Skip to content
This repository
Browse code

asserting that under_scored names result in valid ClassNames

  • Loading branch information...
commit 5190b9f2c91f5ac2adf36ce529c1be53ff89e8f2 1 parent bed5453
Mark authored August 08, 2012
1  lib/Cake/Console/Command/SchemaShell.php
@@ -96,6 +96,7 @@ public function startup() {
96 96
 				$name = $plugin;
97 97
 			}
98 98
 		}
  99
+		$name = Inflector::classify($name);
99 100
 		$this->Schema = new CakeSchema(compact('name', 'path', 'file', 'connection', 'plugin'));
100 101
 	}
101 102
 
29  lib/Cake/Test/Case/Console/Command/SchemaShellTest.php
@@ -499,6 +499,35 @@ public function testPluginParam() {
499 499
 	}
500 500
 
501 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
+
  530
+/**
502 531
  * test that using Plugin.name with write.
503 532
  *
504 533
  * @return void

0 notes on commit 5190b9f

Please sign in to comment.
Something went wrong with that request. Please try again.