Commit 455ad18f authored by Ghislain Loas's avatar Ghislain Loas

dev #56034 endle english plural

parent 4904c4eb
......@@ -29,9 +29,9 @@ THE SOFTWARE.
* Used to generate on-the-fly method names and attributes for Storm_Model_Abstract mainly
*/
class Storm_Inflector {
protected static $_singular = ['/eux$/i' => 'eu',
protected static $_singular = ['/activities$/i' => 'activity',
'/eux$/i' => 'eu',
'/aux$/i' => 'al',
'/ies$/i' => 'y',
'/s$/i' => ''];
protected static $_plural = ['/eu$/i'=> 'eux',
......
<?php
/*
STORM is under the MIT License (MIT)
STORM is under the MIT License (MIT)
Copyright (c) 2010-2011 Agence Française Informatique http://www.afi-sa.fr
Copyright (c) 2010-2011 Agence Française Informatique http://www.afi-sa.fr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
......@@ -33,38 +33,71 @@ abstract class InflectorTestCase extends PHPUnit_Framework_TestCase {
class InflectorPluralizeFrenchTest extends InflectorTestCase {
public function datas() {
class InflectorPluralizeTest extends InflectorTestCase {
public function frensh() {
return [['cheval', 'chevaux'],
['Lieu', 'Lieux'],
['categorie', 'categories'],
['avis', 'avis']];
}
/**
* @test
* @dataProvider datas
public function english() {
return [['item', 'items'],
['category', 'categories']];
}
/**
* @test
* @dataProvider frensh
*/
public function pluralizeShouldReturnPlural($singular, $plural) {
public function pluralizeFrenshShouldReturnPlural($singular, $plural) {
$this->assertEquals($plural, Storm_Inflector::pluralize($singular));
}
/**
* @test
* @dataProvider english
*/
public function pluralizEnglishShouldReturnPlural($singular, $plural) {
$this->assertEquals($plural, Storm_Inflector::pluralize($singular));
}
}
class InflectorSinguralizeFrenchTest extends InflectorTestCase {
public function datas() {
public function frensh() {
return [['chevaux', 'cheval'],
['zork', 'zork'],
['categories', 'categorie'],
['avis', 'avis']];
}
/**
* @test
* @dataProvider datas
public function english() {
return [['activities', 'activity'],
['items', 'item']];
}
/**
* @test
* @dataProvider frensh
*/
public function singuralizeFrenshShouldReturnSingular($plural, $singular) {
$this->assertEquals($singular, Storm_Inflector::singularize($plural));
}
/**
* @test
* @dataProvider english
*/
public function singuralizeShouldReturnSingular($plural, $singular) {
public function singuralizeEnglishShouldReturnSingular($plural, $singular) {
$this->assertEquals($singular, Storm_Inflector::singularize($plural));
}
}
......@@ -77,8 +110,8 @@ class InflectorCamelizeFrenchTest extends InflectorTestCase {
['ID_NEWS', 'IdNews']];
}
/**
* @test
/**
* @test
* @dataProvider datas
*/
public function camelizeNEWSShouldReturnNews($value, $camelized) {
......@@ -96,8 +129,8 @@ class InflectorUnderscorizeFrenchTest extends InflectorTestCase {
['ABoireEtAManger', 'a_boire_et_a_manger']];
}
/**
* @test
/**
* @test
* @dataProvider datas
*/
public function underscorizeShouldReturnUnderscorized($value, $expected) {
......
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