mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding inflection rule for empty string. Fixes #5325. Tests added.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7509 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
fc012dc32f
commit
6086e96a61
2 changed files with 3 additions and 2 deletions
|
@ -97,6 +97,7 @@ class Inflector extends Object {
|
||||||
'/(alias)$/i' => '\1es',
|
'/(alias)$/i' => '\1es',
|
||||||
'/(ax|cri|test)is$/i' => '\1es',
|
'/(ax|cri|test)is$/i' => '\1es',
|
||||||
'/s$/' => 's',
|
'/s$/' => 's',
|
||||||
|
'/^$/' => '',
|
||||||
'/$/' => 's');
|
'/$/' => 's');
|
||||||
|
|
||||||
$coreUninflectedPlural = array(
|
$coreUninflectedPlural = array(
|
||||||
|
@ -164,7 +165,6 @@ class Inflector extends Object {
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function pluralize($word) {
|
function pluralize($word) {
|
||||||
|
|
||||||
$_this =& Inflector::getInstance();
|
$_this =& Inflector::getInstance();
|
||||||
if (!isset($_this->pluralRules) || empty($_this->pluralRules)) {
|
if (!isset($_this->pluralRules) || empty($_this->pluralRules)) {
|
||||||
$_this->__initPluralRules();
|
$_this->__initPluralRules();
|
||||||
|
|
|
@ -104,6 +104,7 @@ class InflectorTest extends CakeTestCase {
|
||||||
$this->assertEqual(Inflector::singularize('knives'), 'knife');
|
$this->assertEqual(Inflector::singularize('knives'), 'knife');
|
||||||
$this->assertEqual(Inflector::singularize('wolves'), 'wolf');
|
$this->assertEqual(Inflector::singularize('wolves'), 'wolf');
|
||||||
$this->assertEqual(Inflector::singularize('shelves'), 'shelf');
|
$this->assertEqual(Inflector::singularize('shelves'), 'shelf');
|
||||||
|
$this->assertEqual(Inflector::singularize(''), '');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testInflectingPlurals method
|
* testInflectingPlurals method
|
||||||
|
@ -145,7 +146,7 @@ class InflectorTest extends CakeTestCase {
|
||||||
$this->assertEqual(Inflector::pluralize('person'), 'people');
|
$this->assertEqual(Inflector::pluralize('person'), 'people');
|
||||||
$this->assertEqual(Inflector::pluralize('people'), 'people');
|
$this->assertEqual(Inflector::pluralize('people'), 'people');
|
||||||
$this->assertEqual(Inflector::pluralize('glove'), 'gloves');
|
$this->assertEqual(Inflector::pluralize('glove'), 'gloves');
|
||||||
|
$this->assertEqual(Inflector::pluralize(''), '');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* testInflectorSlug method
|
* testInflectorSlug method
|
||||||
|
|
Loading…
Reference in a new issue