bug #11560 Plural fix (1emming)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #11560).
Discussion
----------
Plural fix
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no*
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #11517
| License | MIT
*BC note - this breaks code if people build on top of the incorrect returned value `drife`.
Fixes the `singular` for `drives`. I've added more test values to prove more edge cases and to show this changes doesn't break other `singular`-look ups.
In the test class i've added a few `known issues` for later reference/fixure.
Commits
-------
9b550d6
Plural fix
This commit is contained in:
commit
e17276b197
@ -75,6 +75,9 @@ class StringUtil
|
|||||||
// objectives (objective), alternative (alternatives)
|
// objectives (objective), alternative (alternatives)
|
||||||
array('sevit', 5, true, true, 'tive'),
|
array('sevit', 5, true, true, 'tive'),
|
||||||
|
|
||||||
|
// drives (drive)
|
||||||
|
array('sevird', 6, false, true, 'drive'),
|
||||||
|
|
||||||
// lives (life), wives (wife)
|
// lives (life), wives (wife)
|
||||||
array('sevi', 4, false, true, 'ife'),
|
array('sevi', 4, false, true, 'ife'),
|
||||||
|
|
||||||
|
@ -20,114 +20,127 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase
|
|||||||
// see http://english-zone.com/spelling/plurals.html
|
// see http://english-zone.com/spelling/plurals.html
|
||||||
// see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English
|
// see http://www.scribd.com/doc/3271143/List-of-100-Irregular-Plural-Nouns-in-English
|
||||||
return array(
|
return array(
|
||||||
array('tags', 'tag'),
|
array('accesses', 'access'),
|
||||||
|
array('addresses', 'address'),
|
||||||
|
array('agendas', 'agenda'),
|
||||||
|
array('alumnae', 'alumna'),
|
||||||
array('alumni', 'alumnus'),
|
array('alumni', 'alumnus'),
|
||||||
array('funguses', array('fungus', 'funguse', 'fungusis')),
|
|
||||||
array('fungi', 'fungus'),
|
|
||||||
array('axes', array('ax', 'axe', 'axis')),
|
|
||||||
array('appendices', array('appendex', 'appendix', 'appendice')),
|
|
||||||
array('indices', array('index', 'indix', 'indice')),
|
|
||||||
array('prices', array('prex', 'prix', 'price')),
|
|
||||||
array('indexes', 'index'),
|
|
||||||
array('children', 'child'),
|
|
||||||
array('men', 'man'),
|
|
||||||
array('women', 'woman'),
|
|
||||||
array('oxen', 'ox'),
|
|
||||||
array('bacteria', array('bacterion', 'bacterium')),
|
|
||||||
array('criteria', array('criterion', 'criterium')),
|
|
||||||
array('feet', 'foot'),
|
|
||||||
array('nebulae', 'nebula'),
|
|
||||||
array('babies', 'baby'),
|
|
||||||
array('hooves', array('hoof', 'hoove', 'hooff')),
|
|
||||||
array('chateaux', 'chateau'),
|
|
||||||
array('echoes', array('echo', 'echoe')),
|
|
||||||
array('analyses', array('analys', 'analyse', 'analysis')),
|
array('analyses', array('analys', 'analyse', 'analysis')),
|
||||||
array('theses', array('thes', 'these', 'thesis')),
|
|
||||||
array('foci', 'focus'),
|
|
||||||
array('focuses', array('focus', 'focuse', 'focusis')),
|
|
||||||
array('oases', array('oas', 'oase', 'oasis')),
|
|
||||||
array('matrices', array('matrex', 'matrix', 'matrice')),
|
|
||||||
array('matrixes', 'matrix'),
|
|
||||||
array('bureaus', 'bureau'),
|
|
||||||
array('bureaux', 'bureau'),
|
|
||||||
array('beaux', 'beau'),
|
|
||||||
array('data', array('daton', 'datum')),
|
|
||||||
array('phenomena', array('phenomenon', 'phenomenum')),
|
|
||||||
array('strata', array('straton', 'stratum')),
|
|
||||||
array('geese', 'goose'),
|
|
||||||
array('teeth', 'tooth'),
|
|
||||||
array('antennae', 'antenna'),
|
array('antennae', 'antenna'),
|
||||||
array('antennas', 'antenna'),
|
array('antennas', 'antenna'),
|
||||||
array('houses', array('hous', 'house', 'housis')),
|
array('appendices', array('appendex', 'appendix', 'appendice')),
|
||||||
array('arches', array('arch', 'arche')),
|
array('arches', array('arch', 'arche')),
|
||||||
array('atlases', array('atlas', 'atlase', 'atlasis')),
|
array('atlases', array('atlas', 'atlase', 'atlasis')),
|
||||||
|
array('axes', array('ax', 'axe', 'axis')),
|
||||||
|
array('babies', 'baby'),
|
||||||
|
array('bacteria', array('bacterion', 'bacterium')),
|
||||||
|
array('bases', array('bas', 'base', 'basis')),
|
||||||
array('batches', array('batch', 'batche')),
|
array('batches', array('batch', 'batche')),
|
||||||
array('bushes', array('bush', 'bushe')),
|
array('beaux', 'beau'),
|
||||||
|
array('bees', array('be', 'bee')),
|
||||||
|
array('boxes', 'box'),
|
||||||
|
array('boys', 'boy'),
|
||||||
|
array('bureaus', 'bureau'),
|
||||||
|
array('bureaux', 'bureau'),
|
||||||
array('buses', array('bus', 'buse', 'busis')),
|
array('buses', array('bus', 'buse', 'busis')),
|
||||||
|
array('bushes', array('bush', 'bushe')),
|
||||||
array('calves', array('calf', 'calve', 'calff')),
|
array('calves', array('calf', 'calve', 'calff')),
|
||||||
|
array('cars', 'car'),
|
||||||
|
array('cassettes', array('cassett', 'cassette')),
|
||||||
|
array('caves', array('caf', 'cave', 'caff')),
|
||||||
|
array('chateaux', 'chateau'),
|
||||||
|
array('cheeses', array('chees', 'cheese', 'cheesis')),
|
||||||
|
array('children', 'child'),
|
||||||
array('circuses', array('circus', 'circuse', 'circusis')),
|
array('circuses', array('circus', 'circuse', 'circusis')),
|
||||||
|
array('cliffs', 'cliff'),
|
||||||
array('crises', array('cris', 'crise', 'crisis')),
|
array('crises', array('cris', 'crise', 'crisis')),
|
||||||
|
array('criteria', array('criterion', 'criterium')),
|
||||||
|
array('cups', 'cup'),
|
||||||
|
array('data', array('daton', 'datum')),
|
||||||
|
array('days', 'day'),
|
||||||
|
array('discos', 'disco'),
|
||||||
|
array('drives', 'drive'),
|
||||||
|
array('drivers', 'driver'),
|
||||||
array('dwarves', array('dwarf', 'dwarve', 'dwarff')),
|
array('dwarves', array('dwarf', 'dwarve', 'dwarff')),
|
||||||
|
array('echoes', array('echo', 'echoe')),
|
||||||
array('elves', array('elf', 'elve', 'elff')),
|
array('elves', array('elf', 'elve', 'elff')),
|
||||||
array('emphases', array('emphas', 'emphase', 'emphasis')),
|
array('emphases', array('emphas', 'emphase', 'emphasis')),
|
||||||
array('faxes', 'fax'),
|
array('faxes', 'fax'),
|
||||||
|
array('feet', 'foot'),
|
||||||
|
array('foci', 'focus'),
|
||||||
|
array('focuses', array('focus', 'focuse', 'focusis')),
|
||||||
|
array('formulae', 'formula'),
|
||||||
|
array('formulas', 'formula'),
|
||||||
|
array('fungi', 'fungus'),
|
||||||
|
array('funguses', array('fungus', 'funguse', 'fungusis')),
|
||||||
|
array('garages', array('garag', 'garage')),
|
||||||
|
array('geese', 'goose'),
|
||||||
array('halves', array('half', 'halve', 'halff')),
|
array('halves', array('half', 'halve', 'halff')),
|
||||||
|
array('hats', 'hat'),
|
||||||
array('heroes', array('hero', 'heroe')),
|
array('heroes', array('hero', 'heroe')),
|
||||||
|
array('hippopotamuses', array('hippopotamus', 'hippopotamuse', 'hippopotamusis')), //hippopotami
|
||||||
array('hoaxes', 'hoax'),
|
array('hoaxes', 'hoax'),
|
||||||
|
array('hooves', array('hoof', 'hoove', 'hooff')),
|
||||||
|
array('houses', array('hous', 'house', 'housis')),
|
||||||
|
array('indexes', 'index'),
|
||||||
|
array('indices', array('index', 'indix', 'indice')),
|
||||||
|
array('ions', 'ion'),
|
||||||
array('irises', array('iris', 'irise', 'irisis')),
|
array('irises', array('iris', 'irise', 'irisis')),
|
||||||
array('kisses', 'kiss'),
|
array('kisses', 'kiss'),
|
||||||
array('addresses', 'address'),
|
|
||||||
array('accesses', 'access'),
|
|
||||||
array('knives', 'knife'),
|
array('knives', 'knife'),
|
||||||
array('lives', 'life'),
|
array('lamps', 'lamp'),
|
||||||
|
array('leaves', array('leaf', 'leave', 'leaff')),
|
||||||
array('lice', 'louse'),
|
array('lice', 'louse'),
|
||||||
|
array('lives', 'life'),
|
||||||
|
array('matrices', array('matrex', 'matrix', 'matrice')),
|
||||||
|
array('matrixes', 'matrix'),
|
||||||
|
array('men', 'man'),
|
||||||
array('mice', 'mouse'),
|
array('mice', 'mouse'),
|
||||||
|
array('moves', 'move'),
|
||||||
|
array('nebulae', 'nebula'),
|
||||||
array('neuroses', array('neuros', 'neurose', 'neurosis')),
|
array('neuroses', array('neuros', 'neurose', 'neurosis')),
|
||||||
|
array('oases', array('oas', 'oase', 'oasis')),
|
||||||
|
array('objectives', 'objective'),
|
||||||
|
array('oxen', 'ox'),
|
||||||
|
array('parties', 'party'),
|
||||||
|
array('phenomena', array('phenomenon', 'phenomenum')),
|
||||||
|
array('photos', 'photo'),
|
||||||
|
array('pianos', 'piano'),
|
||||||
array('plateaux', 'plateau'),
|
array('plateaux', 'plateau'),
|
||||||
array('poppies', 'poppy'),
|
array('poppies', 'poppy'),
|
||||||
|
array('prices', array('prex', 'prix', 'price')),
|
||||||
array('quizzes', 'quiz'),
|
array('quizzes', 'quiz'),
|
||||||
array('scarves', array('scarf', 'scarve', 'scarff')),
|
|
||||||
array('spies', 'spy'),
|
|
||||||
array('stories', 'story'),
|
|
||||||
array('syllabi', 'syllabus'),
|
|
||||||
array('thieves', array('thief', 'thieve', 'thieff')),
|
|
||||||
array('waltzes', array('waltz', 'waltze')),
|
|
||||||
array('wharves', array('wharf', 'wharve', 'wharff')),
|
|
||||||
array('caves', array('caf', 'cave', 'caff')),
|
|
||||||
array('staves', array('staf', 'stave', 'staff')),
|
|
||||||
array('wives', 'wife'),
|
|
||||||
array('ions', 'ion'),
|
|
||||||
array('bases', array('bas', 'base', 'basis')),
|
|
||||||
array('cars', 'car'),
|
|
||||||
array('cassettes', array('cassett', 'cassette')),
|
|
||||||
array('lamps', 'lamp'),
|
|
||||||
array('hats', 'hat'),
|
|
||||||
array('cups', 'cup'),
|
|
||||||
array('boxes', 'box'),
|
|
||||||
array('sandwiches', array('sandwich', 'sandwiche')),
|
|
||||||
array('suitcases', array('suitcas', 'suitcase', 'suitcasis')),
|
|
||||||
array('roses', array('ros', 'rose', 'rosis')),
|
|
||||||
array('garages', array('garag', 'garage')),
|
|
||||||
array('shoes', array('sho', 'shoe')),
|
|
||||||
array('days', 'day'),
|
|
||||||
array('boys', 'boy'),
|
|
||||||
array('roofs', 'roof'),
|
|
||||||
array('cliffs', 'cliff'),
|
|
||||||
array('sheriffs', 'sheriff'),
|
|
||||||
array('discos', 'disco'),
|
|
||||||
array('pianos', 'piano'),
|
|
||||||
array('photos', 'photo'),
|
|
||||||
array('trees', array('tre', 'tree')),
|
|
||||||
array('bees', array('be', 'bee')),
|
|
||||||
array('cheeses', array('chees', 'cheese', 'cheesis')),
|
|
||||||
array('radii', 'radius'),
|
array('radii', 'radius'),
|
||||||
array('objectives', 'objective'),
|
array('roofs', 'roof'),
|
||||||
array('moves', 'move'),
|
array('roses', array('ros', 'rose', 'rosis')),
|
||||||
|
array('sandwiches', array('sandwich', 'sandwiche')),
|
||||||
|
array('scarves', array('scarf', 'scarve', 'scarff')),
|
||||||
|
array('schemas', 'schema'), //schemata
|
||||||
|
array('sheriffs', 'sheriff'),
|
||||||
|
array('shoes', array('sho', 'shoe')),
|
||||||
|
array('spies', 'spy'),
|
||||||
|
array('staves', array('staf', 'stave', 'staff')),
|
||||||
|
array('stories', 'story'),
|
||||||
|
array('strata', array('straton', 'stratum')),
|
||||||
|
array('suitcases', array('suitcas', 'suitcase', 'suitcasis')),
|
||||||
|
array('syllabi', 'syllabus'),
|
||||||
|
array('tags', 'tag'),
|
||||||
|
array('teeth', 'tooth'),
|
||||||
|
array('theses', array('thes', 'these', 'thesis')),
|
||||||
|
array('thieves', array('thief', 'thieve', 'thieff')),
|
||||||
|
array('trees', array('tre', 'tree')),
|
||||||
|
array('waltzes', array('waltz', 'waltze')),
|
||||||
|
array('wives', 'wife'),
|
||||||
|
|
||||||
// test casing: if the first letter was uppercase, it should remain so
|
// test casing: if the first letter was uppercase, it should remain so
|
||||||
array('Men', 'Man'),
|
array('Men', 'Man'),
|
||||||
array('GrandChildren', 'GrandChild'),
|
array('GrandChildren', 'GrandChild'),
|
||||||
array('SubTrees', array('SubTre', 'SubTree')),
|
array('SubTrees', array('SubTre', 'SubTree')),
|
||||||
|
|
||||||
|
// Known issues
|
||||||
|
//array('insignia', 'insigne'),
|
||||||
|
//array('insignias', 'insigne'),
|
||||||
|
//array('rattles', 'rattle'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +149,13 @@ class StringUtilTest extends \PHPUnit_Framework_TestCase
|
|||||||
*/
|
*/
|
||||||
public function testSingularify($plural, $singular)
|
public function testSingularify($plural, $singular)
|
||||||
{
|
{
|
||||||
$this->assertEquals($singular, StringUtil::singularify($plural));
|
$single = StringUtil::singularify($plural);
|
||||||
|
if (is_string($singular) && is_array($single)) {
|
||||||
|
$this->fail("--- Expected\n`string`: " . $singular . "\n+++ Actual\n`array`: " . implode(', ', $single));
|
||||||
|
} elseif (is_array($singular) && is_string($single)) {
|
||||||
|
$this->fail("--- Expected\n`array`: " . implode(', ', $singular) . "\n+++ Actual\n`string`: " . $single);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertEquals($singular, $single);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user