Skip to content

Commit

Permalink
Fix regression in camelize().
Browse files Browse the repository at this point in the history
The input should not be lowercased before camelizing, as this can cause
inputs that were previously camelized to create incorrect results.

Refs #6735
  • Loading branch information
markstory committed Jun 5, 2015
1 parent b8b5243 commit 239c839
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/Cake/Test/Case/Utility/InflectorTest.php
Expand Up @@ -460,6 +460,20 @@ public function testInflectorUnderscore() {
$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
*
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Utility/Inflector.php
Expand Up @@ -500,7 +500,6 @@ public static function underscore($camelCasedWord) {
*/
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);
Expand Down

0 comments on commit 239c839

Please sign in to comment.