Added ability to singularize 'gloves', 'wolves', 'shelves' and other ves words. Added tests. Closes #5080

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7335 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2008-07-12 00:22:09 +00:00
parent 96fa4e4db1
commit 20851bd548
2 changed files with 10 additions and 2 deletions

View file

@ -232,7 +232,7 @@ class Inflector extends Object {
'/(tive)s$/i' => '\1',
'/(hive)s$/i' => '\1',
'/(drive)s$/i' => '\1',
'/([^f])ves$/i' => '\1fe',
'/([^fo])ves$/i' => '\1fe',
'/(^analy)ses$/i' => '\1sis',
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
'/([ti])a$/i' => '\1um',

View file

@ -34,7 +34,7 @@ App::import('Core', 'Inflector');
* @package cake.tests
* @subpackage cake.tests.cases.libs
*/
class InflectorTest extends UnitTestCase {
class InflectorTest extends CakeTestCase {
/**
* Inflector property
*
@ -98,6 +98,12 @@ class InflectorTest extends UnitTestCase {
$this->assertEqual(Inflector::singularize('termini'), 'terminus');
$this->assertEqual(Inflector::singularize('viri'), 'virus');
$this->assertEqual(Inflector::singularize('people'), 'person');
$this->assertEqual(Inflector::singularize('gloves'), 'glove');
$this->assertEqual(Inflector::singularize('doves'), 'dove');
$this->assertEqual(Inflector::singularize('lives'), 'life');
$this->assertEqual(Inflector::singularize('knives'), 'knife');
$this->assertEqual(Inflector::singularize('wolves'), 'wolf');
$this->assertEqual(Inflector::singularize('shelves'), 'shelf');
}
/**
* testInflectingPlurals method
@ -138,6 +144,8 @@ class InflectorTest extends UnitTestCase {
$this->assertEqual(Inflector::pluralize('virus'), 'viri');
$this->assertEqual(Inflector::pluralize('person'), 'people');
$this->assertEqual(Inflector::pluralize('people'), 'people');
$this->assertEqual(Inflector::pluralize('glove'), 'gloves');
}
/**
* testInflectorSlug method