mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding fix for irregular inflections returning word in lowercase
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5065 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
b71eede168
commit
5d7ce86000
2 changed files with 10 additions and 2 deletions
|
@ -177,7 +177,7 @@ class Inflector extends Object {
|
|||
}
|
||||
|
||||
if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
|
||||
$_this->pluralized[$word] = $regs[1] . $irregular[strtolower($regs[2])];
|
||||
$_this->pluralized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
|
||||
return $_this->pluralized[$word];
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ class Inflector extends Object {
|
|||
}
|
||||
|
||||
if (preg_match('/(.*)\\b(' . $regexIrregular . ')$/i', $word, $regs)) {
|
||||
$_this->singularized[$word] = $regs[1] . $irregular[strtolower($regs[2])];
|
||||
$_this->singularized[$word] = $regs[1] . substr($word, 0, 1) . substr($irregular[strtolower($regs[2])], 1);
|
||||
return $_this->singularized[$word];
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,10 @@ class InflectorTest extends UnitTestCase {
|
|||
$expected = 'menu';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->inflector->singularize('Menus');
|
||||
$expected = 'Menu';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->inflector->singularize('houses');
|
||||
$expected = 'house';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
@ -111,6 +115,10 @@ class InflectorTest extends UnitTestCase {
|
|||
$expected = 'menus';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->inflector->pluralize('Menu');
|
||||
$expected = 'Menus';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$result = $this->inflector->pluralize('quiz');
|
||||
$expected = 'quizzes';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
|
Loading…
Add table
Reference in a new issue