mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
b8b524392d
commit
239c83938f
2 changed files with 14 additions and 1 deletions
|
@ -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
|
||||
*
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue