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:
phpnut 2007-05-13 00:28:03 +00:00
parent b71eede168
commit 5d7ce86000
2 changed files with 10 additions and 2 deletions

View file

@ -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];
}

View file

@ -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);