diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index 09371de10..c4bf31625 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -120,7 +120,6 @@ class Inflector extends Object { 'hoof' => 'hoofs', 'loaf' => 'loaves', 'man' => 'men', - 'menu' => 'menus', 'money' => 'monies', 'mongoose' => 'mongooses', 'move' => 'moves', @@ -206,6 +205,7 @@ class Inflector extends Object { $_this =& Inflector::getInstance(); $coreSingularRules = array('/(s)tatuses$/i' => '\1\2tatus', + '/^(.*)(menu)s$/i' => '\1\2', '/(quiz)zes$/i' => '\\1', '/(matr)ices$/i' => '\1ix', '/(vert|ind)ices$/i' => '\1ex', @@ -234,9 +234,10 @@ class Inflector extends Object { '/(m)en$/i' => '\1an', '/(c)hildren$/i' => '\1\2hild', '/(n)ews$/i' => '\1\2ews', + '/^(.*us)$/' => '\\1', '/s$/i' => ''); - $coreUninflectedSingular = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', '.*us', '.*ss', 'Amoyese', + $coreUninflectedSingular = array('.*[nrlm]ese', '.*deer', '.*fish', '.*measles', '.*ois', '.*pox', '.*sheep', '.*ss', 'Amoyese', 'bison', 'Borghese', 'bream', 'breeches', 'britches', 'buffalo', 'cantus', 'carp', 'chassis', 'clippers', 'cod', 'coitus', 'Congoese', 'contretemps', 'corps', 'debris', 'diabetes', 'djinn', 'eland', 'elk', 'equipment', 'Faroese', 'flounder', 'Foochowese', 'gallows', 'Genevese', 'Genoese', 'Gilbertese', 'graffiti', @@ -260,7 +261,6 @@ class Inflector extends Object { 'hoofs' => 'hoof', 'loaves' => 'loaf', 'men' => 'man', - 'menus' => 'menu', 'monies' => 'money', 'mongooses' => 'mongoose', 'moves' => 'move', @@ -300,7 +300,6 @@ class Inflector extends Object { * @static */ function singularize($word) { - $_this =& Inflector::getInstance(); if (!isset($_this->singularRules) || empty($_this->singularRules)) { $_this->__initSingularRules(); diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php index 26dd3a267..3609f8ee5 100644 --- a/cake/tests/cases/libs/inflector.test.php +++ b/cake/tests/cases/libs/inflector.test.php @@ -45,10 +45,18 @@ class InflectorTest extends UnitTestCase { $expected = 'menu'; $this->assertEqual($result, $expected); + $result = $this->inflector->singularize('food_menus'); + $expected = 'food_menu'; + $this->assertEqual($result, $expected); + $result = $this->inflector->singularize('Menus'); $expected = 'Menu'; $this->assertEqual($result, $expected); + $result = $this->inflector->singularize('FoodMenus'); + $expected = 'FoodMenu'; + $this->assertEqual($result, $expected); + $result = $this->inflector->singularize('houses'); $expected = 'house'; $this->assertEqual($result, $expected); @@ -92,7 +100,7 @@ class InflectorTest extends UnitTestCase { $result = $this->inflector->singularize('Alias'); $expected = 'Alias'; $this->assertEqual($result, $expected); - + $result = $this->inflector->singularize('Media'); $expected = 'Media'; $this->assertEqual($result, $expected); @@ -119,10 +127,18 @@ class InflectorTest extends UnitTestCase { $expected = 'menus'; $this->assertEqual($result, $expected); + $result = $this->inflector->pluralize('food_menu'); + $expected = 'food_menus'; + $this->assertEqual($result, $expected); + $result = $this->inflector->pluralize('Menu'); $expected = 'Menus'; $this->assertEqual($result, $expected); + $result = $this->inflector->pluralize('FoodMenu'); + $expected = 'FoodMenus'; + $this->assertEqual($result, $expected); + $result = $this->inflector->pluralize('quiz'); $expected = 'quizzes'; $this->assertEqual($result, $expected); @@ -150,7 +166,7 @@ class InflectorTest extends UnitTestCase { $result = $this->inflector->pluralize('Aliases'); $expected = 'Aliases'; $this->assertEqual($result, $expected); - + $result = $this->inflector->pluralize('Media'); $expected = 'Media'; $this->assertEqual($result, $expected);