From 239c83938f1c238900fef1ab0996a6cfd9975727 Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 5 Jun 2015 10:20:51 -0400 Subject: [PATCH] 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 --- lib/Cake/Test/Case/Utility/InflectorTest.php | 14 ++++++++++++++ lib/Cake/Utility/Inflector.php | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index 8635f39f4..9f54ee1fc 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -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 * diff --git a/lib/Cake/Utility/Inflector.php b/lib/Cake/Utility/Inflector.php index d06d4baff..6863d95bb 100644 --- a/lib/Cake/Utility/Inflector.php +++ b/lib/Cake/Utility/Inflector.php @@ -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);