Commit 05523640 by Antonio Ramirez

fixed pluralize + singularize rules for tests

parent 7b98b424
......@@ -23,7 +23,12 @@ class Inflector
*/
protected static $plural = array(
'rules' => array(
'/(m)ove$/i' => '\1oves',
'/(f)oot$/i' => '\1eet',
'/(h)uman$/i' => '\1umans',
'/(s)tatus$/i' => '\1\2tatuses',
'/(s)taff$/i' => '\1taff',
'/(t)ooth$/i' => '\1eeth',
'/(quiz)$/i' => '\1zes',
'/^(ox)$/i' => '\1\2en',
'/([m|l])ouse$/i' => '\1ice',
......@@ -37,7 +42,7 @@ class Inflector
'/(p)erson$/i' => '\1eople',
'/(m)an$/i' => '\1en',
'/(c)hild$/i' => '\1hildren',
'/(buffal|tomat)o$/i' => '\1\2oes',
'/(buffal|tomat|potat|ech|her|vet)o$/i' => '\1oes',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i',
'/us$/i' => 'uses',
'/(alias)$/i' => '\1es',
......@@ -97,6 +102,8 @@ class Inflector
protected static $singular = array(
'rules' => array(
'/(s)tatuses$/i' => '\1\2tatus',
'/(f)eet$/i' => '\1oot',
'/(t)eeth$/i' => '\1ooth',
'/^(.*)(menu)s$/i' => '\1\2',
'/(quiz)zes$/i' => '\\1',
'/(matr)ices$/i' => '\1ix',
......
......@@ -39,10 +39,28 @@ class InflectorTest extends TestCase
public function testSingularize()
{
$this->assertEquals("person", Inflector::singularize('people'));
$this->assertEquals("fish", Inflector::singularize('fish'));
$this->assertEquals("man", Inflector::singularize('men'));
$this->assertEquals("table", Inflector::singularize('tables'));
$testData = array(
'moves' => 'move',
'feet' => 'foot',
'children' => 'child',
'humans' => 'human',
'men' => 'man',
'staff' => 'staff',
'teeth' => 'tooth',
'people' => 'person',
'mice' => 'mouse',
'touches' => 'touch',
'hashes' => 'hash',
'shelves' => 'shelf',
'potatoes' => 'potato',
'buses' => 'bus',
'tests' => 'test',
'cars' => 'car',
);
foreach ($testData as $testIn => $testOut) {
$this->assertEquals($testOut, Inflector::pluralize($testIn));
$this->assertEquals(ucfirst($testOut), ucfirst(Inflector::pluralize($testIn)));
}
}
public function testTitleize()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment