Fix regression in camelize().

The input should not be lowercased before camelizing, as this can cause
inputs that were previously camelized to create incorrect results.

Refs #6735
This commit is contained in:
mark_story 2015-06-05 10:20:51 -04:00
parent b8b524392d
commit 239c83938f
2 changed files with 14 additions and 1 deletions

View file

@ -460,6 +460,20 @@ class InflectorTest extends CakeTestCase {
$this->assertSame(Inflector::underscore(false), '');
}
/**
* Test camelize()
*
* @return void
*/
public function testCamelize() {
$this->assertSame('BlogArticles', Inflector::camelize('blog_articles'));
$this->assertSame('BlogArticles', Inflector::camelize('blog articles'));
$this->assertSame('MyPlugin.MyClass', Inflector::camelize('MyPlugin.MyClass'));
$this->assertSame('MyPlugin.MyClass', Inflector::camelize('my_plugin.MyClass'));
$this->assertSame('MyPlugin.myClass', Inflector::camelize('MyPlugin.my_class'));
}
/**
* testVariableNaming method
*

View file

@ -500,7 +500,6 @@ class Inflector {
*/
public static function humanize($lowerCaseAndUnderscoredWord) {
if (!($result = self::_cache(__FUNCTION__, $lowerCaseAndUnderscoredWord))) {
$lowerCaseAndUnderscoredWord = self::underscore($lowerCaseAndUnderscoredWord);
$result = explode(' ', str_replace('_', ' ', $lowerCaseAndUnderscoredWord));
foreach ($result as &$word) {
$word = mb_strtoupper(mb_substr($word, 0, 1)) . mb_substr($word, 1);