From edd7ec421485888ad7fe4999d1c44485ffba24c0 Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Mon, 20 May 2013 00:38:25 +0200 Subject: [PATCH 1/9] Inflector second revision --- yii/helpers/base/Inflector.php | 58 ++++++++++------------------------ 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/yii/helpers/base/Inflector.php b/yii/helpers/base/Inflector.php index 8c2d487c26..33b3dec04a 100644 --- a/yii/helpers/base/Inflector.php +++ b/yii/helpers/base/Inflector.php @@ -357,22 +357,15 @@ class Inflector * Converts an underscored or CamelCase word into a English * sentence. * - * The titleize function converts text like "WelcomePage", - * "welcome_page" or "welcome page" to this "Welcome - * Page". - * If second parameter is set to 'first' it will only - * capitalize the first character of the title. - * - * @param string $word Word to format as tile - * @param string $uppercase If set to 'first' it will only uppercase the - * first character. Otherwise it will uppercase all - * the words in the title. - * @return string Text formatted as title + * @param string $words + * @param bool $ucAll whether to set all words to uppercase + * @return string */ - public static function titleize($word, $uppercase = '') + public static function titleize($words, $ucAll = false) { - $uppercase = $uppercase == 'first' ? 'ucfirst' : 'ucwords'; - return $uppercase(static::humanize(static::underscore($word))); + + $words = static::humanize(static::underscore($words), $ucAll); + return $ucAll ? ucwords($words) : ucfirst($words); } /** @@ -383,8 +376,8 @@ class Inflector * "who's online" will be converted to "WhoSOnline" * * @see variablize - * @param string $word Word to convert to camel case - * @return string UpperCamelCasedWord + * @param string $word the word to CamelCase + * @return string */ public static function camelize($word) { @@ -392,44 +385,27 @@ class Inflector } /** - * Converts a word "into_it_s_underscored_version" + * Converts any "CamelCased" or "ordinary Word" into an "underscored_word". * - * Convert any "CamelCased" or "ordinary Word" into an - * "underscored_word". - * - * This can be really useful for creating friendly URLs. - * - * @access public - * @static - * @param string $word Word to underscore - * @return string Underscored word + * @param string $words the word(s) to underscore + * @return string */ - public static function underscore($word) + public static function underscore($words) { - return strtolower( - preg_replace( - '/[^A-Z^a-z^0-9]+/', - '_', - preg_replace( - '/([a-zd])([A-Z])/', - '1_2', - preg_replace('/([A-Z]+)([A-Z][a-z])/', '1_2', $word) - ) - ) - ); + return strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $words)); } /** * Returns a human-readable string from $word * * @param string $word the string to humanize - * @param bool $uppercase whether to set all words to uppercase or not + * @param bool $ucAll whether to set all words to uppercase or not * @return string */ - public static function humanize($word, $uppercase = false) + public static function humanize($word, $ucAll = false) { $word = str_replace('_', ' ', preg_replace('/_id$/', '', $word)); - return $uppercase ? ucwords($word) : ucfirst($word); + return $ucAll ? ucwords($word) : ucfirst($word); } /** From 82a6281c659e7245872438319081ea4518a42cdd Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Tue, 21 May 2013 01:04:28 +0200 Subject: [PATCH 2/9] added tests --- .../unit/framework/helpers/InflectorTest.php | 51 +++++++++++++++++++ yii/helpers/Inflector.php | 18 +++++++ yii/helpers/base/Inflector.php | 2 +- 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 tests/unit/framework/helpers/InflectorTest.php create mode 100644 yii/helpers/Inflector.php diff --git a/tests/unit/framework/helpers/InflectorTest.php b/tests/unit/framework/helpers/InflectorTest.php new file mode 100644 index 0000000000..4d0f133938 --- /dev/null +++ b/tests/unit/framework/helpers/InflectorTest.php @@ -0,0 +1,51 @@ +assertEquals("people", Inflector::pluralize('person')); + $this->assertEquals("fish", Inflector::pluralize('fish')); + $this->assertEquals("men", Inflector::pluralize('man')); + $this->assertEquals("tables", Inflector::pluralize('table')); + } + + 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')); + } + + public function testTitleize() + { + $this->assertEquals("Me my self and i", Inflector::titleize('MeMySelfAndI')); + $this->assertEquals("Me My Self And I", Inflector::titleize('MeMySelfAndI', true)); + } + + public function testCamelize() + { + $this->assertEquals("MeMySelfAndI", Inflector::camelize('me my_self-andI')); + } + + public function testUnderscore() + { + $this->assertEquals("me_my_self_and_i", Inflector::underscore('Me my self and I')); + } + + public function testHumanize() + { + $this->assertEquals("Me my self and i", Inflector::humanize('me_my_self_and_i')); + $this->assertEquals("Me My Self And i", Inflector::humanize('me_my_self_and_i'), true); + } + +} diff --git a/yii/helpers/Inflector.php b/yii/helpers/Inflector.php new file mode 100644 index 0000000000..72f77a77f5 --- /dev/null +++ b/yii/helpers/Inflector.php @@ -0,0 +1,18 @@ + + * @since 2.0 + */ +class Inflector extends base\Inflector +{ +} diff --git a/yii/helpers/base/Inflector.php b/yii/helpers/base/Inflector.php index 33b3dec04a..51317c8860 100644 --- a/yii/helpers/base/Inflector.php +++ b/yii/helpers/base/Inflector.php @@ -10,7 +10,7 @@ namespace yii\helpers\base; use Yii; /** - * Inflector pluralizes and singularizes English nouns. It also contains other useful methods. + * Inflector pluralizes and singularizes English nouns. It also contains some other useful methods. * * @author Antonio Ramirez * @since 2.0 From 3575b99650e57d26e52497d90598ef0a2b378f82 Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Tue, 21 May 2013 08:22:20 +0200 Subject: [PATCH 3/9] finished all tests --- .../unit/framework/helpers/InflectorTest.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/unit/framework/helpers/InflectorTest.php b/tests/unit/framework/helpers/InflectorTest.php index 4d0f133938..36700f49ed 100644 --- a/tests/unit/framework/helpers/InflectorTest.php +++ b/tests/unit/framework/helpers/InflectorTest.php @@ -48,4 +48,28 @@ class InflectorTest extends TestCase $this->assertEquals("Me My Self And i", Inflector::humanize('me_my_self_and_i'), true); } + public function testVariablize() + { + $this->assertEquals("customerTable", Inflector::variablize('customer_table')); + } + + public function testTableize() + { + $this->assertEquals("customer_tables", Inflector::tableize('customerTable')); + } + + public function testSlug() + { + $this->assertEquals("this-is-a-title", Inflector::humanize('this is a title')); + } + + public function testClassify() + { + $this->assertEquals("CustomerTable", Inflector::classify('customer_tables')); + } + + public function testOrdinalize() + { + $this->assertEquals("21st", Inflector::humanize('21')); + } } From f9222a083a4e09e5ebde5189e389de358206f973 Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Tue, 21 May 2013 08:42:38 +0200 Subject: [PATCH 4/9] fix failing test --- tests/unit/framework/helpers/InflectorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/framework/helpers/InflectorTest.php b/tests/unit/framework/helpers/InflectorTest.php index 36700f49ed..859d8bf789 100644 --- a/tests/unit/framework/helpers/InflectorTest.php +++ b/tests/unit/framework/helpers/InflectorTest.php @@ -39,7 +39,7 @@ class InflectorTest extends TestCase public function testUnderscore() { - $this->assertEquals("me_my_self_and_i", Inflector::underscore('Me my self and I')); + $this->assertEquals("me_my_self_and_i", Inflector::underscore('MeMySelfAndI')); } public function testHumanize() From 20e18e1bdd702f041c8eba8505f29f3133925fae Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Tue, 21 May 2013 11:35:19 +0200 Subject: [PATCH 5/9] fix phpdoc of underscore --- yii/helpers/base/Inflector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yii/helpers/base/Inflector.php b/yii/helpers/base/Inflector.php index 51317c8860..af3f266c01 100644 --- a/yii/helpers/base/Inflector.php +++ b/yii/helpers/base/Inflector.php @@ -385,7 +385,7 @@ class Inflector } /** - * Converts any "CamelCased" or "ordinary Word" into an "underscored_word". + * Converts any "CamelCased" into an "underscored_word". * * @param string $words the word(s) to underscore * @return string From 641e6ee7cfae41c87b9c00a711c081391b35a3be Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Wed, 22 May 2013 08:34:17 +0200 Subject: [PATCH 6/9] ported inflection methods from StringHelper to Inflector helper class --- framework/yii/base/Model.php | 4 +- framework/yii/db/ActiveRecord.php | 5 +- framework/yii/helpers/base/StringHelper.php | 80 ------------------- .../framework/helpers/StringHelperTest.php | 52 ------------ 4 files changed, 5 insertions(+), 136 deletions(-) diff --git a/framework/yii/base/Model.php b/framework/yii/base/Model.php index 98901bfdb0..c7432f5f77 100644 --- a/framework/yii/base/Model.php +++ b/framework/yii/base/Model.php @@ -9,7 +9,7 @@ namespace yii\base; use ArrayObject; use ArrayIterator; -use yii\helpers\StringHelper; +use yii\helpers\Inflector; use yii\validators\RequiredValidator; use yii\validators\Validator; @@ -504,7 +504,7 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess */ public function generateAttributeLabel($name) { - return StringHelper::camel2words($name, true); + return Inflector::camel2words($name, true); } /** diff --git a/framework/yii/db/ActiveRecord.php b/framework/yii/db/ActiveRecord.php index 2b7d2b8898..dd90782d02 100644 --- a/framework/yii/db/ActiveRecord.php +++ b/framework/yii/db/ActiveRecord.php @@ -18,6 +18,7 @@ use yii\db\Connection; use yii\db\TableSchema; use yii\db\Expression; use yii\helpers\StringHelper; +use yii\helpers\Inflector; /** * ActiveRecord is the base class for classes representing relational data in terms of objects. @@ -261,14 +262,14 @@ class ActiveRecord extends Model /** * Declares the name of the database table associated with this AR class. - * By default this method returns the class name as the table name by calling [[StringHelper::camel2id()]] + * By default this method returns the class name as the table name by calling [[Inflector::camel2id()]] * with prefix 'tbl_'. For example, 'Customer' becomes 'tbl_customer', and 'OrderItem' becomes * 'tbl_order_item'. You may override this method if the table is not named after this convention. * @return string the table name */ public static function tableName() { - return 'tbl_' . StringHelper::camel2id(StringHelper::basename(get_called_class()), '_'); + return 'tbl_' . Inflector::camel2id(StringHelper::basename(get_called_class()), '_'); } /** diff --git a/framework/yii/helpers/base/StringHelper.php b/framework/yii/helpers/base/StringHelper.php index 646bcbb3b0..5b854acb6b 100644 --- a/framework/yii/helpers/base/StringHelper.php +++ b/framework/yii/helpers/base/StringHelper.php @@ -65,84 +65,4 @@ class StringHelper } return $path; } - - /** - * Converts a word to its plural form. - * Note that this is for English only! - * For example, 'apple' will become 'apples', and 'child' will become 'children'. - * @param string $name the word to be pluralized - * @return string the pluralized word - */ - public static function pluralize($name) - { - static $rules = array( - '/(m)ove$/i' => '\1oves', - '/(f)oot$/i' => '\1eet', - '/(c)hild$/i' => '\1hildren', - '/(h)uman$/i' => '\1umans', - '/(m)an$/i' => '\1en', - '/(s)taff$/i' => '\1taff', - '/(t)ooth$/i' => '\1eeth', - '/(p)erson$/i' => '\1eople', - '/([m|l])ouse$/i' => '\1ice', - '/(x|ch|ss|sh|us|as|is|os)$/i' => '\1es', - '/([^aeiouy]|qu)y$/i' => '\1ies', - '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', - '/(shea|lea|loa|thie)f$/i' => '\1ves', - '/([ti])um$/i' => '\1a', - '/(tomat|potat|ech|her|vet)o$/i' => '\1oes', - '/(bu)s$/i' => '\1ses', - '/(ax|test)is$/i' => '\1es', - '/s$/' => 's', - ); - foreach ($rules as $rule => $replacement) { - if (preg_match($rule, $name)) { - return preg_replace($rule, $replacement, $name); - } - } - return $name . 's'; - } - - /** - * Converts a CamelCase name into space-separated words. - * For example, 'PostTag' will be converted to 'Post Tag'. - * @param string $name the string to be converted - * @param boolean $ucwords whether to capitalize the first letter in each word - * @return string the resulting words - */ - public static function camel2words($name, $ucwords = true) - { - $label = trim(strtolower(str_replace(array('-', '_', '.'), ' ', preg_replace('/(?assertEquals('ั', StringHelper::substr('ัั‚ะพ', 0, 2)); } - public function testPluralize() - { - $testData = array( - 'move' => 'moves', - 'foot' => 'feet', - 'child' => 'children', - 'human' => 'humans', - 'man' => 'men', - 'staff' => 'staff', - 'tooth' => 'teeth', - 'person' => 'people', - 'mouse' => 'mice', - 'touch' => 'touches', - 'hash' => 'hashes', - 'shelf' => 'shelves', - 'potato' => 'potatoes', - 'bus' => 'buses', - 'test' => 'tests', - 'car' => 'cars', - ); - - foreach ($testData as $testIn => $testOut) { - $this->assertEquals($testOut, StringHelper::pluralize($testIn)); - $this->assertEquals(ucfirst($testOut), ucfirst(StringHelper::pluralize($testIn))); - } - } - - public function testCamel2words() - { - $this->assertEquals('Camel Case', StringHelper::camel2words('camelCase')); - $this->assertEquals('Lower Case', StringHelper::camel2words('lower_case')); - $this->assertEquals('Tricky Stuff It Is Testing', StringHelper::camel2words(' tricky_stuff.it-is testing... ')); - } - - public function testCamel2id() - { - $this->assertEquals('post-tag', StringHelper::camel2id('PostTag')); - $this->assertEquals('post_tag', StringHelper::camel2id('PostTag', '_')); - - $this->assertEquals('post-tag', StringHelper::camel2id('postTag')); - $this->assertEquals('post_tag', StringHelper::camel2id('postTag', '_')); - } - - public function testId2camel() - { - $this->assertEquals('PostTag', StringHelper::id2camel('post-tag')); - $this->assertEquals('PostTag', StringHelper::id2camel('post_tag', '_')); - - $this->assertEquals('PostTag', StringHelper::id2camel('post-tag')); - $this->assertEquals('PostTag', StringHelper::id2camel('post_tag', '_')); - } - public function testBasename() { $this->assertEquals('', StringHelper::basename('')); From 7b98b4241873735dc8517dbb3a05e72634f3ddfa Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Wed, 22 May 2013 08:35:03 +0200 Subject: [PATCH 7/9] added inflection methods from StringHelper + some comment fixes --- {yii => framework/yii}/helpers/Inflector.php | 0 .../yii}/helpers/base/Inflector.php | 82 +++++++++++++------ .../unit/framework/helpers/InflectorTest.php | 54 ++++++++++-- 3 files changed, 107 insertions(+), 29 deletions(-) rename {yii => framework/yii}/helpers/Inflector.php (100%) rename {yii => framework/yii}/helpers/base/Inflector.php (83%) diff --git a/yii/helpers/Inflector.php b/framework/yii/helpers/Inflector.php similarity index 100% rename from yii/helpers/Inflector.php rename to framework/yii/helpers/Inflector.php diff --git a/yii/helpers/base/Inflector.php b/framework/yii/helpers/base/Inflector.php similarity index 83% rename from yii/helpers/base/Inflector.php rename to framework/yii/helpers/base/Inflector.php index af3f266c01..f23354735c 100644 --- a/yii/helpers/base/Inflector.php +++ b/framework/yii/helpers/base/Inflector.php @@ -290,10 +290,11 @@ class Inflector ); /** - * Returns the plural of a $word - * - * @param string $word the word to pluralize - * @return string + * Converts a word to its plural form. + * Note that this is for English only! + * For example, 'apple' will become 'apples', and 'child' will become 'children'. + * @param string $word the word to be pluralized + * @return string the pluralized word */ public static function pluralize($word) { @@ -319,7 +320,6 @@ class Inflector /** * Returns the singular of the $word - * * @param string $word the english word to singularize * @return string Singular noun. */ @@ -356,7 +356,6 @@ class Inflector /** * Converts an underscored or CamelCase word into a English * sentence. - * * @param string $words * @param bool $ucAll whether to set all words to uppercase * @return string @@ -370,11 +369,9 @@ class Inflector /** * Returns given word as CamelCased - * * Converts a word like "send_email" to "SendEmail". It * will remove non alphanumeric character from the word, so * "who's online" will be converted to "WhoSOnline" - * * @see variablize * @param string $word the word to CamelCase * @return string @@ -384,20 +381,65 @@ class Inflector return str_replace(' ', '', ucwords(preg_replace('/[^A-Z^a-z^0-9]+/', ' ', $word))); } + /** + * Converts a CamelCase name into space-separated words. + * For example, 'PostTag' will be converted to 'Post Tag'. + * @param string $name the string to be converted + * @param boolean $ucwords whether to capitalize the first letter in each word + * @return string the resulting words + */ + public static function camel2words($name, $ucwords = true) + { + $label = trim(strtolower(str_replace(array( + '-', + '_', + '.' + ), ' ', preg_replace('/(?assertEquals("people", Inflector::pluralize('person')); - $this->assertEquals("fish", Inflector::pluralize('fish')); - $this->assertEquals("men", Inflector::pluralize('man')); - $this->assertEquals("tables", Inflector::pluralize('table')); + $testData = array( + 'move' => 'moves', + 'foot' => 'feet', + 'child' => 'children', + 'human' => 'humans', + 'man' => 'men', + 'staff' => 'staff', + 'tooth' => 'teeth', + 'person' => 'people', + 'mouse' => 'mice', + 'touch' => 'touches', + 'hash' => 'hashes', + 'shelf' => 'shelves', + 'potato' => 'potatoes', + 'bus' => 'buses', + 'test' => 'tests', + 'car' => 'cars', + ); + + foreach ($testData as $testIn => $testOut) { + $this->assertEquals($testOut, Inflector::pluralize($testIn)); + $this->assertEquals(ucfirst($testOut), ucfirst(Inflector::pluralize($testIn))); + } } public function testSingularize() @@ -42,10 +61,35 @@ class InflectorTest extends TestCase $this->assertEquals("me_my_self_and_i", Inflector::underscore('MeMySelfAndI')); } + public function testCamel2words() + { + $this->assertEquals('Camel Case', Inflector::camel2words('camelCase')); + $this->assertEquals('Lower Case', Inflector::camel2words('lower_case')); + $this->assertEquals('Tricky Stuff It Is Testing', Inflector::camel2words(' tricky_stuff.it-is testing... ')); + } + + public function testCamel2id() + { + $this->assertEquals('post-tag', Inflector::camel2id('PostTag')); + $this->assertEquals('post_tag', Inflector::camel2id('PostTag', '_')); + + $this->assertEquals('post-tag', Inflector::camel2id('postTag')); + $this->assertEquals('post_tag', Inflector::camel2id('postTag', '_')); + } + + public function testId2camel() + { + $this->assertEquals('PostTag', Inflector::id2camel('post-tag')); + $this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_')); + + $this->assertEquals('PostTag', Inflector::id2camel('post-tag')); + $this->assertEquals('PostTag', Inflector::id2camel('post_tag', '_')); + } + public function testHumanize() { $this->assertEquals("Me my self and i", Inflector::humanize('me_my_self_and_i')); - $this->assertEquals("Me My Self And i", Inflector::humanize('me_my_self_and_i'), true); + $this->assertEquals("Me My Self And I", Inflector::humanize('me_my_self_and_i'), true); } public function testVariablize() From 05523640f2a65ae09b75480a445b085b5dca5077 Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Wed, 22 May 2013 10:59:09 +0200 Subject: [PATCH 8/9] fixed pluralize + singularize rules for tests --- framework/yii/helpers/base/Inflector.php | 9 ++++++- .../unit/framework/helpers/InflectorTest.php | 26 ++++++++++++++++--- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/framework/yii/helpers/base/Inflector.php b/framework/yii/helpers/base/Inflector.php index f23354735c..3c1927c4b7 100644 --- a/framework/yii/helpers/base/Inflector.php +++ b/framework/yii/helpers/base/Inflector.php @@ -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', diff --git a/tests/unit/framework/helpers/InflectorTest.php b/tests/unit/framework/helpers/InflectorTest.php index 49c958ec26..ee6050cb18 100644 --- a/tests/unit/framework/helpers/InflectorTest.php +++ b/tests/unit/framework/helpers/InflectorTest.php @@ -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() From dc8dbdc64a969da181f7e13a7a2dee0898753f7b Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Wed, 22 May 2013 11:04:08 +0200 Subject: [PATCH 9/9] fixed tests --- tests/unit/framework/helpers/InflectorTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/unit/framework/helpers/InflectorTest.php b/tests/unit/framework/helpers/InflectorTest.php index ee6050cb18..9f9626dd34 100644 --- a/tests/unit/framework/helpers/InflectorTest.php +++ b/tests/unit/framework/helpers/InflectorTest.php @@ -58,8 +58,8 @@ class InflectorTest extends TestCase 'cars' => 'car', ); foreach ($testData as $testIn => $testOut) { - $this->assertEquals($testOut, Inflector::pluralize($testIn)); - $this->assertEquals(ucfirst($testOut), ucfirst(Inflector::pluralize($testIn))); + $this->assertEquals($testOut, Inflector::singularize($testIn)); + $this->assertEquals(ucfirst($testOut), ucfirst(Inflector::singularize($testIn))); } } @@ -107,7 +107,7 @@ class InflectorTest extends TestCase public function testHumanize() { $this->assertEquals("Me my self and i", Inflector::humanize('me_my_self_and_i')); - $this->assertEquals("Me My Self And I", Inflector::humanize('me_my_self_and_i'), true); + $this->assertEquals("Me My Self And I", Inflector::humanize('me_my_self_and_i', true)); } public function testVariablize() @@ -122,7 +122,7 @@ class InflectorTest extends TestCase public function testSlug() { - $this->assertEquals("this-is-a-title", Inflector::humanize('this is a title')); + $this->assertEquals("this-is-a-title", Inflector::slug('this is a title')); } public function testClassify() @@ -132,6 +132,6 @@ class InflectorTest extends TestCase public function testOrdinalize() { - $this->assertEquals("21st", Inflector::humanize('21')); + $this->assertEquals('21st', Inflector::ordinalize('21')); } }