pictcode / lib / Cake / Test / Case / Utility / InflectorTest.php @ 680ede59
履歴 | 表示 | アノテート | ダウンロード (27.004 KB)
| 1 | 
      <?php
     | 
  
|---|---|
| 2 | 
      /**
     | 
  
| 3 | 
       * InflectorTest
     | 
  
| 4 | 
       *
     | 
  
| 5 | 
       * InflectorTest is used to test cases on the Inflector class
     | 
  
| 6 | 
       *
     | 
  
| 7 | 
       * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
     | 
  
| 8 | 
       * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
     | 
  
| 9 | 
       *
     | 
  
| 10 | 
       * Licensed under The MIT License
     | 
  
| 11 | 
       * For full copyright and license information, please see the LICENSE.txt
     | 
  
| 12 | 
       * Redistributions of files must retain the above copyright notice.
     | 
  
| 13 | 
       *
     | 
  
| 14 | 
       * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
     | 
  
| 15 | 
       * @link          http://book.cakephp.org/2.0/en/development/testing.html
     | 
  
| 16 | 
       * @package       Cake.Test.Case.Utility
     | 
  
| 17 | 
       * @since         CakePHP(tm) v 1.2.0.4206
     | 
  
| 18 | 
       * @license       http://www.opensource.org/licenses/mit-license.php MIT License
     | 
  
| 19 | 
       */
     | 
  
| 20 | 
       | 
  
| 21 | 
      /**
     | 
  
| 22 | 
       * Included libraries.
     | 
  
| 23 | 
       */
     | 
  
| 24 | 
      App::uses('Inflector', 'Utility');  | 
  
| 25 | 
       | 
  
| 26 | 
      /**
     | 
  
| 27 | 
       * Short description for class.
     | 
  
| 28 | 
       *
     | 
  
| 29 | 
       * @package       Cake.Test.Case.Utility
     | 
  
| 30 | 
       */
     | 
  
| 31 | 
      class InflectorTest extends CakeTestCase {  | 
  
| 32 | 
       | 
  
| 33 | 
      /**
     | 
  
| 34 | 
       * A list of chars to test transliteration.
     | 
  
| 35 | 
       *
     | 
  
| 36 | 
       * @var array
     | 
  
| 37 | 
       */
     | 
  
| 38 | 
      public static $maps = array (  | 
  
| 39 | 
      'de' => array ( /* German */  | 
  
| 40 | 
      'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue', 'ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'ß' => 'ss',  | 
  
| 41 | 
      'ẞ' => 'SS'  | 
  
| 42 | 
      ),  | 
  
| 43 | 
      'latin' => array (  | 
  
| 44 | 
      'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Å' => 'A', 'Ă' => 'A', 'Æ' => 'AE', 'Ç' =>  | 
  
| 45 | 
      'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I',  | 
  
| 46 | 
      'Ï' => 'I', 'Ð' => 'D', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ő' => 'O', 'Ø' => 'O',  | 
  
| 47 | 
      'Ș' => 'S', 'Ț' => 'T', 'Ù' => 'U', 'Ú' => 'U', 'Û' => 'U', 'Ű' => 'U',  | 
  
| 48 | 
      'Ý' => 'Y', 'Þ' => 'TH', 'à' => 'a', 'á' => 'a', 'â' => 'a', 'ã' => 'a',  | 
  
| 49 | 
      'å' => 'a', 'ă' => 'a', 'æ' => 'ae', 'ç' => 'c', 'è' => 'e', 'é' => 'e', 'ê' => 'e', 'ë' => 'e',  | 
  
| 50 | 
      'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'd', 'ñ' => 'n', 'ò' => 'o', 'ó' =>  | 
  
| 51 | 
      'o', 'ô' => 'o', 'õ' => 'o', 'ő' => 'o', 'ø' => 'o', 'ș' => 's', 'ț' => 't', 'ù' => 'u', 'ú' => 'u',  | 
  
| 52 | 
      'û' => 'u', 'ű' => 'u', 'ý' => 'y', 'þ' => 'th', 'ÿ' => 'y'  | 
  
| 53 | 
      ),  | 
  
| 54 | 
      'tr' => array ( /* Turkish */  | 
  
| 55 | 
      'ş' => 's', 'Ş' => 'S', 'ı' => 'i', 'İ' => 'I', 'ç' => 'c', 'Ç' => 'C', 'ğ' => 'g', 'Ğ' => 'G'  | 
  
| 56 | 
      ),  | 
  
| 57 | 
      'uk' => array ( /* Ukrainian */  | 
  
| 58 | 
      'Є' => 'Ye', 'І' => 'I', 'Ї' => 'Yi', 'Ґ' => 'G', 'є' => 'ye', 'і' => 'i', 'ї' => 'yi', 'ґ' => 'g'  | 
  
| 59 | 
      ),  | 
  
| 60 | 
      'cs' => array ( /* Czech */  | 
  
| 61 | 
      'č' => 'c', 'ď' => 'd', 'ě' => 'e', 'ň' => 'n', 'ř' => 'r', 'š' => 's', 'ť' => 't', 'ů' => 'u',  | 
  
| 62 | 
      'ž' => 'z', 'Č' => 'C', 'Ď' => 'D', 'Ě' => 'E', 'Ň' => 'N', 'Ř' => 'R', 'Š' => 'S', 'Ť' => 'T',  | 
  
| 63 | 
      'Ů' => 'U', 'Ž' => 'Z'  | 
  
| 64 | 
      ),  | 
  
| 65 | 
      'pl' => array ( /* Polish */  | 
  
| 66 | 
      'ą' => 'a', 'ć' => 'c', 'ę' => 'e', 'ł' => 'l', 'ń' => 'n', 'ó' => 'o', 'ś' => 's', 'ź' => 'z',  | 
  
| 67 | 
      'ż' => 'z', 'Ą' => 'A', 'Ć' => 'C', 'Ł' => 'L', 'Ń' => 'N', 'Ó' => 'O', 'Ś' => 'S',  | 
  
| 68 | 
      'Ź' => 'Z', 'Ż' => 'Z'  | 
  
| 69 | 
      ),  | 
  
| 70 | 
      'ro' => array ( /* Romanian */  | 
  
| 71 | 
      'ă' => 'a', 'â' => 'a', 'î' => 'i', 'ș' => 's', 'ț' => 't', 'Ţ' => 'T', 'ţ' => 't'  | 
  
| 72 | 
      ),  | 
  
| 73 | 
      'lv' => array ( /* Latvian */  | 
  
| 74 | 
      'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n',  | 
  
| 75 | 
      'š' => 's', 'ū' => 'u', 'ž' => 'z', 'Ā' => 'A', 'Č' => 'C', 'Ē' => 'E', 'Ģ' => 'G', 'Ī' => 'I',  | 
  
| 76 | 
      'Ķ' => 'K', 'Ļ' => 'L', 'Ņ' => 'N', 'Š' => 'S', 'Ū' => 'U', 'Ž' => 'Z'  | 
  
| 77 | 
      ),  | 
  
| 78 | 
      'lt' => array ( /* Lithuanian */  | 
  
| 79 | 
      'ą' => 'a', 'č' => 'c', 'ę' => 'e', 'ė' => 'e', 'į' => 'i', 'š' => 's', 'ų' => 'u', 'ū' => 'u', 'ž' => 'z',  | 
  
| 80 | 
      'Ą' => 'A', 'Č' => 'C', 'Ę' => 'E', 'Ė' => 'E', 'Į' => 'I', 'Š' => 'S', 'Ų' => 'U', 'Ū' => 'U', 'Ž' => 'Z'  | 
  
| 81 | 
      )  | 
  
| 82 | 
      );  | 
  
| 83 | 
       | 
  
| 84 | 
      /**
     | 
  
| 85 | 
       * tearDown
     | 
  
| 86 | 
       *
     | 
  
| 87 | 
       * @return void
     | 
  
| 88 | 
       */
     | 
  
| 89 | 
      public function tearDown() {  | 
  
| 90 | 
                      parent::tearDown();
     | 
  
| 91 | 
      Inflector::reset();  | 
  
| 92 | 
      }  | 
  
| 93 | 
       | 
  
| 94 | 
      /**
     | 
  
| 95 | 
       * testInflectingSingulars method
     | 
  
| 96 | 
       *
     | 
  
| 97 | 
       * @return void
     | 
  
| 98 | 
       */
     | 
  
| 99 | 
      public function testInflectingSingulars() {  | 
  
| 100 | 
      $this->assertEquals(Inflector::singularize('categorias'), 'categoria');  | 
  
| 101 | 
      $this->assertEquals(Inflector::singularize('menus'), 'menu');  | 
  
| 102 | 
      $this->assertEquals(Inflector::singularize('news'), 'news');  | 
  
| 103 | 
      $this->assertEquals(Inflector::singularize('food_menus'), 'food_menu');  | 
  
| 104 | 
      $this->assertEquals(Inflector::singularize('Menus'), 'Menu');  | 
  
| 105 | 
      $this->assertEquals(Inflector::singularize('FoodMenus'), 'FoodMenu');  | 
  
| 106 | 
      $this->assertEquals(Inflector::singularize('houses'), 'house');  | 
  
| 107 | 
      $this->assertEquals(Inflector::singularize('powerhouses'), 'powerhouse');  | 
  
| 108 | 
      $this->assertEquals(Inflector::singularize('quizzes'), 'quiz');  | 
  
| 109 | 
      $this->assertEquals(Inflector::singularize('Buses'), 'Bus');  | 
  
| 110 | 
      $this->assertEquals(Inflector::singularize('buses'), 'bus');  | 
  
| 111 | 
      $this->assertEquals(Inflector::singularize('matrix_rows'), 'matrix_row');  | 
  
| 112 | 
      $this->assertEquals(Inflector::singularize('matrices'), 'matrix');  | 
  
| 113 | 
      $this->assertEquals(Inflector::singularize('vertices'), 'vertex');  | 
  
| 114 | 
      $this->assertEquals(Inflector::singularize('indices'), 'index');  | 
  
| 115 | 
      $this->assertEquals(Inflector::singularize('Aliases'), 'Alias');  | 
  
| 116 | 
      $this->assertEquals(Inflector::singularize('Alias'), 'Alias');  | 
  
| 117 | 
      $this->assertEquals(Inflector::singularize('Media'), 'Media');  | 
  
| 118 | 
      $this->assertEquals(Inflector::singularize('NodeMedia'), 'NodeMedia');  | 
  
| 119 | 
      $this->assertEquals(Inflector::singularize('alumni'), 'alumnus');  | 
  
| 120 | 
      $this->assertEquals(Inflector::singularize('bacilli'), 'bacillus');  | 
  
| 121 | 
      $this->assertEquals(Inflector::singularize('cacti'), 'cactus');  | 
  
| 122 | 
      $this->assertEquals(Inflector::singularize('foci'), 'focus');  | 
  
| 123 | 
      $this->assertEquals(Inflector::singularize('fungi'), 'fungus');  | 
  
| 124 | 
      $this->assertEquals(Inflector::singularize('nuclei'), 'nucleus');  | 
  
| 125 | 
      $this->assertEquals(Inflector::singularize('octopuses'), 'octopus');  | 
  
| 126 | 
      $this->assertEquals(Inflector::singularize('octopuses'), 'octopus');  | 
  
| 127 | 
      $this->assertEquals(Inflector::singularize('radii'), 'radius');  | 
  
| 128 | 
      $this->assertEquals(Inflector::singularize('stimuli'), 'stimulus');  | 
  
| 129 | 
      $this->assertEquals(Inflector::singularize('syllabi'), 'syllabus');  | 
  
| 130 | 
      $this->assertEquals(Inflector::singularize('termini'), 'terminus');  | 
  
| 131 | 
      $this->assertEquals(Inflector::singularize('viruses'), 'virus');  | 
  
| 132 | 
      $this->assertEquals(Inflector::singularize('people'), 'person');  | 
  
| 133 | 
      $this->assertEquals(Inflector::singularize('gloves'), 'glove');  | 
  
| 134 | 
      $this->assertEquals(Inflector::singularize('doves'), 'dove');  | 
  
| 135 | 
      $this->assertEquals(Inflector::singularize('lives'), 'life');  | 
  
| 136 | 
      $this->assertEquals(Inflector::singularize('knives'), 'knife');  | 
  
| 137 | 
      $this->assertEquals(Inflector::singularize('wolves'), 'wolf');  | 
  
| 138 | 
      $this->assertEquals(Inflector::singularize('slaves'), 'slave');  | 
  
| 139 | 
      $this->assertEquals(Inflector::singularize('shelves'), 'shelf');  | 
  
| 140 | 
      $this->assertEquals(Inflector::singularize('taxis'), 'taxi');  | 
  
| 141 | 
      $this->assertEquals(Inflector::singularize('taxes'), 'tax');  | 
  
| 142 | 
      $this->assertEquals(Inflector::singularize('Taxes'), 'Tax');  | 
  
| 143 | 
      $this->assertEquals(Inflector::singularize('AwesomeTaxes'), 'AwesomeTax');  | 
  
| 144 | 
      $this->assertEquals(Inflector::singularize('faxes'), 'fax');  | 
  
| 145 | 
      $this->assertEquals(Inflector::singularize('waxes'), 'wax');  | 
  
| 146 | 
      $this->assertEquals(Inflector::singularize('niches'), 'niche');  | 
  
| 147 | 
      $this->assertEquals(Inflector::singularize('caves'), 'cave');  | 
  
| 148 | 
      $this->assertEquals(Inflector::singularize('graves'), 'grave');  | 
  
| 149 | 
      $this->assertEquals(Inflector::singularize('waves'), 'wave');  | 
  
| 150 | 
      $this->assertEquals(Inflector::singularize('bureaus'), 'bureau');  | 
  
| 151 | 
      $this->assertEquals(Inflector::singularize('genetic_analyses'), 'genetic_analysis');  | 
  
| 152 | 
      $this->assertEquals(Inflector::singularize('doctor_diagnoses'), 'doctor_diagnosis');  | 
  
| 153 | 
      $this->assertEquals(Inflector::singularize('parantheses'), 'paranthesis');  | 
  
| 154 | 
      $this->assertEquals(Inflector::singularize('Causes'), 'Cause');  | 
  
| 155 | 
      $this->assertEquals(Inflector::singularize('colossuses'), 'colossus');  | 
  
| 156 | 
      $this->assertEquals(Inflector::singularize('diagnoses'), 'diagnosis');  | 
  
| 157 | 
      $this->assertEquals(Inflector::singularize('bases'), 'basis');  | 
  
| 158 | 
      $this->assertEquals(Inflector::singularize('analyses'), 'analysis');  | 
  
| 159 | 
      $this->assertEquals(Inflector::singularize('curves'), 'curve');  | 
  
| 160 | 
      $this->assertEquals(Inflector::singularize('cafes'), 'cafe');  | 
  
| 161 | 
      $this->assertEquals(Inflector::singularize('roofs'), 'roof');  | 
  
| 162 | 
      $this->assertEquals(Inflector::singularize('foes'), 'foe');  | 
  
| 163 | 
      $this->assertEquals(Inflector::singularize('databases'), 'database');  | 
  
| 164 | 
      $this->assertEquals(Inflector::singularize('cookies'), 'cookie');  | 
  
| 165 | 
      $this->assertEquals(Inflector::singularize('thieves'), 'thief');  | 
  
| 166 | 
      $this->assertEquals(Inflector::singularize('potatoes'), 'potato');  | 
  
| 167 | 
      $this->assertEquals(Inflector::singularize('heroes'), 'hero');  | 
  
| 168 | 
      $this->assertEquals(Inflector::singularize('buffalos'), 'buffalo');  | 
  
| 169 | 
      $this->assertEquals(Inflector::singularize('babies'), 'baby');  | 
  
| 170 | 
      $this->assertEquals(Inflector::singularize('teeth'), 'tooth');  | 
  
| 171 | 
      $this->assertEquals(Inflector::singularize('geese'), 'goose');  | 
  
| 172 | 
      $this->assertEquals(Inflector::singularize('feet'), 'foot');  | 
  
| 173 | 
      $this->assertEquals(Inflector::singularize('objectives'), 'objective');  | 
  
| 174 | 
      $this->assertEquals(Inflector::singularize('archives'), 'archive');  | 
  
| 175 | 
      $this->assertEquals(Inflector::singularize('briefs'), 'brief');  | 
  
| 176 | 
      $this->assertEquals(Inflector::singularize('quotas'), 'quota');  | 
  
| 177 | 
      $this->assertEquals(Inflector::singularize('curves'), 'curve');  | 
  
| 178 | 
      $this->assertEquals(Inflector::singularize('body_curves'), 'body_curve');  | 
  
| 179 | 
      $this->assertEquals(Inflector::singularize('metadata'), 'metadata');  | 
  
| 180 | 
      $this->assertEquals(Inflector::singularize('files_metadata'), 'files_metadata');  | 
  
| 181 | 
      $this->assertEquals(Inflector::singularize('sieves'), 'sieve');  | 
  
| 182 | 
      $this->assertEquals(Inflector::singularize('blue_octopuses'), 'blue_octopus');  | 
  
| 183 | 
      $this->assertEquals(Inflector::singularize(''), '');  | 
  
| 184 | 
      }  | 
  
| 185 | 
       | 
  
| 186 | 
      /**
     | 
  
| 187 | 
       * Test that overlapping irregulars don't collide.
     | 
  
| 188 | 
       *
     | 
  
| 189 | 
       * @return void
     | 
  
| 190 | 
       */
     | 
  
| 191 | 
      public function testSingularizeMultiWordIrregular() {  | 
  
| 192 | 
      Inflector::rules('singular', array(  | 
  
| 193 | 
      'irregular' => array(  | 
  
| 194 | 
      'preguntas_frecuentes' => 'pregunta_frecuente',  | 
  
| 195 | 
      'categorias_preguntas_frecuentes' => 'categoria_pregunta_frecuente',  | 
  
| 196 | 
      )  | 
  
| 197 | 
      ));  | 
  
| 198 | 
      $this->assertEquals('pregunta_frecuente', Inflector::singularize('preguntas_frecuentes'));  | 
  
| 199 | 
                      $this->assertEquals(
     | 
  
| 200 | 
                              'categoria_pregunta_frecuente',
     | 
  
| 201 | 
      Inflector::singularize('categorias_preguntas_frecuentes')  | 
  
| 202 | 
      );  | 
  
| 203 | 
                      $this->assertEquals(
     | 
  
| 204 | 
                              'faq_categoria_pregunta_frecuente',
     | 
  
| 205 | 
      Inflector::singularize('faq_categorias_preguntas_frecuentes')  | 
  
| 206 | 
      );  | 
  
| 207 | 
      }  | 
  
| 208 | 
       | 
  
| 209 | 
      /**
     | 
  
| 210 | 
       * testInflectingPlurals method
     | 
  
| 211 | 
       *
     | 
  
| 212 | 
       * @return void
     | 
  
| 213 | 
       */
     | 
  
| 214 | 
      public function testInflectingPlurals() {  | 
  
| 215 | 
      $this->assertEquals(Inflector::pluralize('axman'), 'axmen');  | 
  
| 216 | 
      $this->assertEquals(Inflector::pluralize('man'), 'men');  | 
  
| 217 | 
      $this->assertEquals(Inflector::pluralize('woman'), 'women');  | 
  
| 218 | 
      $this->assertEquals(Inflector::pluralize('human'), 'humans');  | 
  
| 219 | 
      $this->assertEquals(Inflector::pluralize('categoria'), 'categorias');  | 
  
| 220 | 
      $this->assertEquals(Inflector::pluralize('house'), 'houses');  | 
  
| 221 | 
      $this->assertEquals(Inflector::pluralize('powerhouse'), 'powerhouses');  | 
  
| 222 | 
      $this->assertEquals(Inflector::pluralize('Bus'), 'Buses');  | 
  
| 223 | 
      $this->assertEquals(Inflector::pluralize('bus'), 'buses');  | 
  
| 224 | 
      $this->assertEquals(Inflector::pluralize('menu'), 'menus');  | 
  
| 225 | 
      $this->assertEquals(Inflector::pluralize('news'), 'news');  | 
  
| 226 | 
      $this->assertEquals(Inflector::pluralize('food_menu'), 'food_menus');  | 
  
| 227 | 
      $this->assertEquals(Inflector::pluralize('Menu'), 'Menus');  | 
  
| 228 | 
      $this->assertEquals(Inflector::pluralize('FoodMenu'), 'FoodMenus');  | 
  
| 229 | 
      $this->assertEquals(Inflector::pluralize('quiz'), 'quizzes');  | 
  
| 230 | 
      $this->assertEquals(Inflector::pluralize('matrix_row'), 'matrix_rows');  | 
  
| 231 | 
      $this->assertEquals(Inflector::pluralize('matrix'), 'matrices');  | 
  
| 232 | 
      $this->assertEquals(Inflector::pluralize('vertex'), 'vertices');  | 
  
| 233 | 
      $this->assertEquals(Inflector::pluralize('index'), 'indices');  | 
  
| 234 | 
      $this->assertEquals(Inflector::pluralize('Alias'), 'Aliases');  | 
  
| 235 | 
      $this->assertEquals(Inflector::pluralize('Aliases'), 'Aliases');  | 
  
| 236 | 
      $this->assertEquals(Inflector::pluralize('Media'), 'Media');  | 
  
| 237 | 
      $this->assertEquals(Inflector::pluralize('NodeMedia'), 'NodeMedia');  | 
  
| 238 | 
      $this->assertEquals(Inflector::pluralize('alumnus'), 'alumni');  | 
  
| 239 | 
      $this->assertEquals(Inflector::pluralize('bacillus'), 'bacilli');  | 
  
| 240 | 
      $this->assertEquals(Inflector::pluralize('cactus'), 'cacti');  | 
  
| 241 | 
      $this->assertEquals(Inflector::pluralize('focus'), 'foci');  | 
  
| 242 | 
      $this->assertEquals(Inflector::pluralize('fungus'), 'fungi');  | 
  
| 243 | 
      $this->assertEquals(Inflector::pluralize('nucleus'), 'nuclei');  | 
  
| 244 | 
      $this->assertEquals(Inflector::pluralize('octopus'), 'octopuses');  | 
  
| 245 | 
      $this->assertEquals(Inflector::pluralize('radius'), 'radii');  | 
  
| 246 | 
      $this->assertEquals(Inflector::pluralize('stimulus'), 'stimuli');  | 
  
| 247 | 
      $this->assertEquals(Inflector::pluralize('syllabus'), 'syllabi');  | 
  
| 248 | 
      $this->assertEquals(Inflector::pluralize('terminus'), 'termini');  | 
  
| 249 | 
      $this->assertEquals(Inflector::pluralize('virus'), 'viruses');  | 
  
| 250 | 
      $this->assertEquals(Inflector::pluralize('person'), 'people');  | 
  
| 251 | 
      $this->assertEquals(Inflector::pluralize('people'), 'people');  | 
  
| 252 | 
      $this->assertEquals(Inflector::pluralize('glove'), 'gloves');  | 
  
| 253 | 
      $this->assertEquals(Inflector::pluralize('crisis'), 'crises');  | 
  
| 254 | 
      $this->assertEquals(Inflector::pluralize('tax'), 'taxes');  | 
  
| 255 | 
      $this->assertEquals(Inflector::pluralize('wave'), 'waves');  | 
  
| 256 | 
      $this->assertEquals(Inflector::pluralize('bureau'), 'bureaus');  | 
  
| 257 | 
      $this->assertEquals(Inflector::pluralize('cafe'), 'cafes');  | 
  
| 258 | 
      $this->assertEquals(Inflector::pluralize('roof'), 'roofs');  | 
  
| 259 | 
      $this->assertEquals(Inflector::pluralize('foe'), 'foes');  | 
  
| 260 | 
      $this->assertEquals(Inflector::pluralize('cookie'), 'cookies');  | 
  
| 261 | 
      $this->assertEquals(Inflector::pluralize('wolf'), 'wolves');  | 
  
| 262 | 
      $this->assertEquals(Inflector::pluralize('thief'), 'thieves');  | 
  
| 263 | 
      $this->assertEquals(Inflector::pluralize('potato'), 'potatoes');  | 
  
| 264 | 
      $this->assertEquals(Inflector::pluralize('hero'), 'heroes');  | 
  
| 265 | 
      $this->assertEquals(Inflector::pluralize('buffalo'), 'buffalo');  | 
  
| 266 | 
      $this->assertEquals(Inflector::pluralize('tooth'), 'teeth');  | 
  
| 267 | 
      $this->assertEquals(Inflector::pluralize('goose'), 'geese');  | 
  
| 268 | 
      $this->assertEquals(Inflector::pluralize('foot'), 'feet');  | 
  
| 269 | 
      $this->assertEquals(Inflector::pluralize('objective'), 'objectives');  | 
  
| 270 | 
      $this->assertEquals(Inflector::pluralize('brief'), 'briefs');  | 
  
| 271 | 
      $this->assertEquals(Inflector::pluralize('quota'), 'quotas');  | 
  
| 272 | 
      $this->assertEquals(Inflector::pluralize('curve'), 'curves');  | 
  
| 273 | 
      $this->assertEquals(Inflector::pluralize('body_curve'), 'body_curves');  | 
  
| 274 | 
      $this->assertEquals(Inflector::pluralize('metadata'), 'metadata');  | 
  
| 275 | 
      $this->assertEquals(Inflector::pluralize('files_metadata'), 'files_metadata');  | 
  
| 276 | 
      $this->assertEquals(Inflector::pluralize('stadia'), 'stadia');  | 
  
| 277 | 
      $this->assertEquals(Inflector::pluralize('sieve'), 'sieves');  | 
  
| 278 | 
      $this->assertEquals(Inflector::pluralize('blue_octopus'), 'blue_octopuses');  | 
  
| 279 | 
      $this->assertEquals(Inflector::pluralize(''), '');  | 
  
| 280 | 
      }  | 
  
| 281 | 
       | 
  
| 282 | 
      /**
     | 
  
| 283 | 
       * Test that overlapping irregulars don't collide.
     | 
  
| 284 | 
       *
     | 
  
| 285 | 
       * @return void
     | 
  
| 286 | 
       */
     | 
  
| 287 | 
      public function testPluralizeMultiWordIrregular() {  | 
  
| 288 | 
      Inflector::rules('plural', array(  | 
  
| 289 | 
      'irregular' => array(  | 
  
| 290 | 
      'mytable1' => 'mytables1',  | 
  
| 291 | 
      'mytable2' => 'mytables2',  | 
  
| 292 | 
      'mytable1_mytable2' => 'mytables1_mytables2',  | 
  
| 293 | 
      'pregunta_frecuente' => 'preguntas_frecuentes',  | 
  
| 294 | 
      'categoria_pregunta_frecuente' => 'categorias_preguntas_frecuentes',  | 
  
| 295 | 
      )  | 
  
| 296 | 
      ));  | 
  
| 297 | 
      $this->assertEquals('preguntas_frecuentes', Inflector::pluralize('pregunta_frecuente'));  | 
  
| 298 | 
                      $this->assertEquals(
     | 
  
| 299 | 
                              'categorias_preguntas_frecuentes',
     | 
  
| 300 | 
      Inflector::pluralize('categoria_pregunta_frecuente')  | 
  
| 301 | 
      );  | 
  
| 302 | 
                      $this->assertEquals(
     | 
  
| 303 | 
                              'faq_categorias_preguntas_frecuentes',
     | 
  
| 304 | 
      Inflector::pluralize('faq_categoria_pregunta_frecuente')  | 
  
| 305 | 
      );  | 
  
| 306 | 
      $this->assertEquals('mytables1', Inflector::pluralize('mytable1'));  | 
  
| 307 | 
      $this->assertEquals('mytables2', Inflector::pluralize('mytable2'));  | 
  
| 308 | 
      $this->assertEquals('mytables1_mytables2', Inflector::pluralize('mytable1_mytable2'));  | 
  
| 309 | 
      $this->assertEquals('mytables1_mytables2', Inflector::tableize('Mytable1Mytable2'));  | 
  
| 310 | 
      }  | 
  
| 311 | 
       | 
  
| 312 | 
      /**
     | 
  
| 313 | 
       * testInflectingMultiWordIrregulars
     | 
  
| 314 | 
       *
     | 
  
| 315 | 
       * @return void
     | 
  
| 316 | 
       */
     | 
  
| 317 | 
      public function testInflectingMultiWordIrregulars() {  | 
  
| 318 | 
                      // unset the default rules in order to avoid them possibly matching
     | 
  
| 319 | 
                      // the words in case the irregular regex won't match, the tests
     | 
  
| 320 | 
                      // should fail in that case
     | 
  
| 321 | 
      Inflector::rules('plural', array(  | 
  
| 322 | 
      'rules' => array(),  | 
  
| 323 | 
      ));  | 
  
| 324 | 
      Inflector::rules('singular', array(  | 
  
| 325 | 
      'rules' => array(),  | 
  
| 326 | 
      ));  | 
  
| 327 | 
       | 
  
| 328 | 
      $this->assertEquals(Inflector::singularize('wisdom teeth'), 'wisdom tooth');  | 
  
| 329 | 
      $this->assertEquals(Inflector::singularize('wisdom-teeth'), 'wisdom-tooth');  | 
  
| 330 | 
      $this->assertEquals(Inflector::singularize('wisdom_teeth'), 'wisdom_tooth');  | 
  
| 331 | 
       | 
  
| 332 | 
      $this->assertEquals(Inflector::pluralize('sweet potato'), 'sweet potatoes');  | 
  
| 333 | 
      $this->assertEquals(Inflector::pluralize('sweet-potato'), 'sweet-potatoes');  | 
  
| 334 | 
      $this->assertEquals(Inflector::pluralize('sweet_potato'), 'sweet_potatoes');  | 
  
| 335 | 
      }  | 
  
| 336 | 
       | 
  
| 337 | 
      /**
     | 
  
| 338 | 
       * testInflectorSlug method
     | 
  
| 339 | 
       *
     | 
  
| 340 | 
       * @return void
     | 
  
| 341 | 
       */
     | 
  
| 342 | 
      public function testInflectorSlug() {  | 
  
| 343 | 
      $result = Inflector::slug('Foo Bar: Not just for breakfast any-more');  | 
  
| 344 | 
      $expected = 'Foo_Bar_Not_just_for_breakfast_any_more';  | 
  
| 345 | 
      $this->assertEquals($expected, $result);  | 
  
| 346 | 
       | 
  
| 347 | 
      $result = Inflector::slug('this/is/a/path');  | 
  
| 348 | 
      $expected = 'this_is_a_path';  | 
  
| 349 | 
      $this->assertEquals($expected, $result);  | 
  
| 350 | 
       | 
  
| 351 | 
      $result = Inflector::slug('Foo Bar: Not just for breakfast any-more', "-");  | 
  
| 352 | 
      $expected = 'Foo-Bar-Not-just-for-breakfast-any-more';  | 
  
| 353 | 
      $this->assertEquals($expected, $result);  | 
  
| 354 | 
       | 
  
| 355 | 
      $result = Inflector::slug('Foo Bar: Not just for breakfast any-more', "+");  | 
  
| 356 | 
      $expected = 'Foo+Bar+Not+just+for+breakfast+any+more';  | 
  
| 357 | 
      $this->assertEquals($expected, $result);  | 
  
| 358 | 
       | 
  
| 359 | 
      $result = Inflector::slug('Äpfel Über Öl grün ärgert groß öko', '-');  | 
  
| 360 | 
      $expected = 'Aepfel-Ueber-Oel-gruen-aergert-gross-oeko';  | 
  
| 361 | 
      $this->assertEquals($expected, $result);  | 
  
| 362 | 
       | 
  
| 363 | 
      $result = Inflector::slug('The truth - and- more- news', '-');  | 
  
| 364 | 
      $expected = 'The-truth-and-more-news';  | 
  
| 365 | 
      $this->assertEquals($expected, $result);  | 
  
| 366 | 
       | 
  
| 367 | 
      $result = Inflector::slug('The truth: and more news', '-');  | 
  
| 368 | 
      $expected = 'The-truth-and-more-news';  | 
  
| 369 | 
      $this->assertEquals($expected, $result);  | 
  
| 370 | 
       | 
  
| 371 | 
      $result = Inflector::slug('La langue française est un attribut de souveraineté en France', '-');  | 
  
| 372 | 
      $expected = 'La-langue-francaise-est-un-attribut-de-souverainete-en-France';  | 
  
| 373 | 
      $this->assertEquals($expected, $result);  | 
  
| 374 | 
       | 
  
| 375 | 
      $result = Inflector::slug('!@$#exciting stuff! - what !@-# was that?', '-');  | 
  
| 376 | 
      $expected = 'exciting-stuff-what-was-that';  | 
  
| 377 | 
      $this->assertEquals($expected, $result);  | 
  
| 378 | 
       | 
  
| 379 | 
      $result = Inflector::slug('20% of profits went to me!', '-');  | 
  
| 380 | 
      $expected = '20-of-profits-went-to-me';  | 
  
| 381 | 
      $this->assertEquals($expected, $result);  | 
  
| 382 | 
       | 
  
| 383 | 
      $result = Inflector::slug('#this melts your face1#2#3', '-');  | 
  
| 384 | 
      $expected = 'this-melts-your-face1-2-3';  | 
  
| 385 | 
      $this->assertEquals($expected, $result);  | 
  
| 386 | 
       | 
  
| 387 | 
      $result = Inflector::slug('controller/action/りんご/1');  | 
  
| 388 | 
      $expected = 'controller_action_りんご_1';  | 
  
| 389 | 
      $this->assertEquals($expected, $result);  | 
  
| 390 | 
       | 
  
| 391 | 
      $result = Inflector::slug('の話が出たので大丈夫かなあと');  | 
  
| 392 | 
      $expected = 'の話が出たので大丈夫かなあと';  | 
  
| 393 | 
      $this->assertEquals($expected, $result);  | 
  
| 394 | 
       | 
  
| 395 | 
      $result = Inflector::slug('posts/view/한국어/page:1/sort:asc');  | 
  
| 396 | 
      $expected = 'posts_view_한국어_page_1_sort_asc';  | 
  
| 397 | 
      $this->assertEquals($expected, $result);  | 
  
| 398 | 
       | 
  
| 399 | 
      $result = Inflector::slug("non\xc2\xa0breaking\xc2\xa0space");  | 
  
| 400 | 
      $this->assertEquals('non_breaking_space', $result);  | 
  
| 401 | 
      }  | 
  
| 402 | 
       | 
  
| 403 | 
      /**
     | 
  
| 404 | 
       * Test slug() with a complete list of special chars.
     | 
  
| 405 | 
       *
     | 
  
| 406 | 
       * @return void
     | 
  
| 407 | 
       */
     | 
  
| 408 | 
      public function testInflectorSlugCharList() {  | 
  
| 409 | 
      foreach (static::$maps as $language => $list) {  | 
  
| 410 | 
      foreach ($list as $from => $to) {  | 
  
| 411 | 
      $result = Inflector::slug($from);  | 
  
| 412 | 
      $this->assertEquals($to, $result, $from . ' (' . $language . ') should be ' . $to . ' - but is ' . $result);  | 
  
| 413 | 
      }  | 
  
| 414 | 
      }  | 
  
| 415 | 
      }  | 
  
| 416 | 
       | 
  
| 417 | 
      /**
     | 
  
| 418 | 
       * testInflectorSlugWithMap method
     | 
  
| 419 | 
       *
     | 
  
| 420 | 
       * @return void
     | 
  
| 421 | 
       */
     | 
  
| 422 | 
      public function testInflectorSlugWithMap() {  | 
  
| 423 | 
      Inflector::rules('transliteration', array('/r/' => '1'));  | 
  
| 424 | 
      $result = Inflector::slug('replace every r');  | 
  
| 425 | 
      $expected = '1eplace_eve1y_1';  | 
  
| 426 | 
      $this->assertEquals($expected, $result);  | 
  
| 427 | 
       | 
  
| 428 | 
      $result = Inflector::slug('replace every r', '_');  | 
  
| 429 | 
      $expected = '1eplace_eve1y_1';  | 
  
| 430 | 
      $this->assertEquals($expected, $result);  | 
  
| 431 | 
      }  | 
  
| 432 | 
       | 
  
| 433 | 
      /**
     | 
  
| 434 | 
       * testInflectorSlugWithMapOverridingDefault method
     | 
  
| 435 | 
       *
     | 
  
| 436 | 
       * @return void
     | 
  
| 437 | 
       */
     | 
  
| 438 | 
      public function testInflectorSlugWithMapOverridingDefault() {  | 
  
| 439 | 
      Inflector::rules('transliteration', array('/å/' => 'aa', '/ø/' => 'oe'));  | 
  
| 440 | 
      $result = Inflector::slug('Testing æ ø å', '-');  | 
  
| 441 | 
      $expected = 'Testing-ae-oe-aa';  | 
  
| 442 | 
      $this->assertEquals($expected, $result);  | 
  
| 443 | 
      }  | 
  
| 444 | 
       | 
  
| 445 | 
      /**
     | 
  
| 446 | 
       * testInflectorUnderscore method
     | 
  
| 447 | 
       *
     | 
  
| 448 | 
       * @return void
     | 
  
| 449 | 
       */
     | 
  
| 450 | 
      public function testInflectorUnderscore() {  | 
  
| 451 | 
      $this->assertSame(Inflector::underscore('TestThing'), 'test_thing');  | 
  
| 452 | 
      $this->assertSame(Inflector::underscore('testThing'), 'test_thing');  | 
  
| 453 | 
      $this->assertSame(Inflector::underscore('TestThingExtra'), 'test_thing_extra');  | 
  
| 454 | 
      $this->assertSame(Inflector::underscore('testThingExtra'), 'test_thing_extra');  | 
  
| 455 | 
      $this->assertSame(Inflector::underscore('testThingExtrå'), 'test_thing_extrå');  | 
  
| 456 | 
       | 
  
| 457 | 
                      // Identical checks test the cache code path.
     | 
  
| 458 | 
      $this->assertSame(Inflector::underscore('TestThing'), 'test_thing');  | 
  
| 459 | 
      $this->assertSame(Inflector::underscore('testThing'), 'test_thing');  | 
  
| 460 | 
      $this->assertSame(Inflector::underscore('TestThingExtra'), 'test_thing_extra');  | 
  
| 461 | 
      $this->assertSame(Inflector::underscore('testThingExtra'), 'test_thing_extra');  | 
  
| 462 | 
      $this->assertSame(Inflector::underscore('testThingExtrå'), 'test_thing_extrå');  | 
  
| 463 | 
       | 
  
| 464 | 
                      // Test stupid values
     | 
  
| 465 | 
      $this->assertSame(Inflector::underscore(''), '');  | 
  
| 466 | 
      $this->assertSame(Inflector::underscore(0), '0');  | 
  
| 467 | 
      $this->assertSame(Inflector::underscore(false), '');  | 
  
| 468 | 
      }  | 
  
| 469 | 
       | 
  
| 470 | 
      /**
     | 
  
| 471 | 
       * Test camelize()
     | 
  
| 472 | 
       *
     | 
  
| 473 | 
       * @return void
     | 
  
| 474 | 
       */
     | 
  
| 475 | 
      public function testCamelize() {  | 
  
| 476 | 
      $this->assertSame('BlogArticles', Inflector::camelize('blog_articles'));  | 
  
| 477 | 
      $this->assertSame('BlogArticles', Inflector::camelize('blog articles'));  | 
  
| 478 | 
      $this->assertSame('MyPlugin.MyClass', Inflector::camelize('MyPlugin.MyClass'));  | 
  
| 479 | 
      $this->assertSame('MyPlugin.MyClass', Inflector::camelize('my_plugin.MyClass'));  | 
  
| 480 | 
      $this->assertSame('MyPlugin.myClass', Inflector::camelize('MyPlugin.my_class'));  | 
  
| 481 | 
      }  | 
  
| 482 | 
       | 
  
| 483 | 
      /**
     | 
  
| 484 | 
       * testVariableNaming method
     | 
  
| 485 | 
       *
     | 
  
| 486 | 
       * @return void
     | 
  
| 487 | 
       */
     | 
  
| 488 | 
      public function testVariableNaming() {  | 
  
| 489 | 
      $this->assertEquals(Inflector::variable('test_field'), 'testField');  | 
  
| 490 | 
      $this->assertEquals(Inflector::variable('test_fieLd'), 'testFieLd');  | 
  
| 491 | 
      $this->assertEquals(Inflector::variable('test field'), 'testField');  | 
  
| 492 | 
      $this->assertEquals(Inflector::variable('Test_field'), 'testField');  | 
  
| 493 | 
      }  | 
  
| 494 | 
       | 
  
| 495 | 
      /**
     | 
  
| 496 | 
       * testClassNaming method
     | 
  
| 497 | 
       *
     | 
  
| 498 | 
       * @return void
     | 
  
| 499 | 
       */
     | 
  
| 500 | 
      public function testClassNaming() {  | 
  
| 501 | 
      $this->assertEquals(Inflector::classify('artists_genres'), 'ArtistsGenre');  | 
  
| 502 | 
      $this->assertEquals(Inflector::classify('file_systems'), 'FileSystem');  | 
  
| 503 | 
      $this->assertEquals(Inflector::classify('news'), 'News');  | 
  
| 504 | 
      $this->assertEquals(Inflector::classify('bureaus'), 'Bureau');  | 
  
| 505 | 
      }  | 
  
| 506 | 
       | 
  
| 507 | 
      /**
     | 
  
| 508 | 
       * testTableNaming method
     | 
  
| 509 | 
       *
     | 
  
| 510 | 
       * @return void
     | 
  
| 511 | 
       */
     | 
  
| 512 | 
      public function testTableNaming() {  | 
  
| 513 | 
      $this->assertEquals('artists_genres', Inflector::tableize('ArtistsGenre'));  | 
  
| 514 | 
      $this->assertEquals('file_systems', Inflector::tableize('FileSystem'));  | 
  
| 515 | 
      $this->assertEquals('news', Inflector::tableize('News'));  | 
  
| 516 | 
      $this->assertEquals('bureaus', Inflector::tableize('Bureau'));  | 
  
| 517 | 
      }  | 
  
| 518 | 
       | 
  
| 519 | 
      /**
     | 
  
| 520 | 
       * testHumanization method
     | 
  
| 521 | 
       *
     | 
  
| 522 | 
       * @return void
     | 
  
| 523 | 
       */
     | 
  
| 524 | 
      public function testHumanization() {  | 
  
| 525 | 
      $this->assertEquals('Posts', Inflector::humanize('posts'));  | 
  
| 526 | 
      $this->assertEquals('Posts Tags', Inflector::humanize('posts_tags'));  | 
  
| 527 | 
      $this->assertEquals('File Systems', Inflector::humanize('file_systems'));  | 
  
| 528 | 
      $this->assertEquals('FiLe SysTems', Inflector::humanize('FiLe_SysTems'));  | 
  
| 529 | 
      $this->assertEquals('Hello Wörld', Inflector::humanize('hello_wörld'));  | 
  
| 530 | 
      $this->assertEquals('福岡 City', Inflector::humanize('福岡_city'));  | 
  
| 531 | 
      }  | 
  
| 532 | 
       | 
  
| 533 | 
      /**
     | 
  
| 534 | 
       * testCustomPluralRule method
     | 
  
| 535 | 
       *
     | 
  
| 536 | 
       * @return void
     | 
  
| 537 | 
       */
     | 
  
| 538 | 
      public function testCustomPluralRule() {  | 
  
| 539 | 
      Inflector::rules('plural', array('/^(custom)$/i' => '\1izables'));  | 
  
| 540 | 
      $this->assertEquals(Inflector::pluralize('custom'), 'customizables');  | 
  
| 541 | 
       | 
  
| 542 | 
      Inflector::rules('plural', array('uninflected' => array('uninflectable')));  | 
  
| 543 | 
      $this->assertEquals(Inflector::pluralize('uninflectable'), 'uninflectable');  | 
  
| 544 | 
       | 
  
| 545 | 
      Inflector::rules('plural', array(  | 
  
| 546 | 
      'rules' => array('/^(alert)$/i' => '\1ables'),  | 
  
| 547 | 
      'uninflected' => array('noflect', 'abtuse'),  | 
  
| 548 | 
      'irregular' => array('amaze' => 'amazable', 'phone' => 'phonezes')  | 
  
| 549 | 
      ));  | 
  
| 550 | 
      $this->assertEquals(Inflector::pluralize('noflect'), 'noflect');  | 
  
| 551 | 
      $this->assertEquals(Inflector::pluralize('abtuse'), 'abtuse');  | 
  
| 552 | 
      $this->assertEquals(Inflector::pluralize('alert'), 'alertables');  | 
  
| 553 | 
      $this->assertEquals(Inflector::pluralize('amaze'), 'amazable');  | 
  
| 554 | 
      $this->assertEquals(Inflector::pluralize('phone'), 'phonezes');  | 
  
| 555 | 
      }  | 
  
| 556 | 
       | 
  
| 557 | 
      /**
     | 
  
| 558 | 
       * testCustomSingularRule method
     | 
  
| 559 | 
       *
     | 
  
| 560 | 
       * @return void
     | 
  
| 561 | 
       */
     | 
  
| 562 | 
      public function testCustomSingularRule() {  | 
  
| 563 | 
      Inflector::rules('singular', array('/(eple)r$/i' => '\1', '/(jente)r$/i' => '\1'));  | 
  
| 564 | 
       | 
  
| 565 | 
      $this->assertEquals(Inflector::singularize('epler'), 'eple');  | 
  
| 566 | 
      $this->assertEquals(Inflector::singularize('jenter'), 'jente');  | 
  
| 567 | 
       | 
  
| 568 | 
      Inflector::rules('singular', array(  | 
  
| 569 | 
      'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'),  | 
  
| 570 | 
      'uninflected' => array('singulars'),  | 
  
| 571 | 
      'irregular' => array('spins' => 'spinor')  | 
  
| 572 | 
      ));  | 
  
| 573 | 
       | 
  
| 574 | 
      $this->assertEquals(Inflector::singularize('inflectors'), 'inflecta');  | 
  
| 575 | 
      $this->assertEquals(Inflector::singularize('contributors'), 'contributa');  | 
  
| 576 | 
      $this->assertEquals(Inflector::singularize('spins'), 'spinor');  | 
  
| 577 | 
      $this->assertEquals(Inflector::singularize('singulars'), 'singulars');  | 
  
| 578 | 
      }  | 
  
| 579 | 
       | 
  
| 580 | 
      /**
     | 
  
| 581 | 
       * testCustomTransliterationRule method
     | 
  
| 582 | 
       *
     | 
  
| 583 | 
       * @return void
     | 
  
| 584 | 
       */
     | 
  
| 585 | 
      public function testCustomTransliterationRule() {  | 
  
| 586 | 
      $this->assertEquals(Inflector::slug('Testing æ ø å'), 'Testing_ae_o_a');  | 
  
| 587 | 
       | 
  
| 588 | 
      Inflector::rules('transliteration', array('/å/' => 'aa', '/ø/' => 'oe'));  | 
  
| 589 | 
      $this->assertEquals(Inflector::slug('Testing æ ø å'), 'Testing_ae_oe_aa');  | 
  
| 590 | 
       | 
  
| 591 | 
      Inflector::rules('transliteration', array('/ä|æ/' => 'ae', '/å/' => 'aa'), true);  | 
  
| 592 | 
      $this->assertEquals(Inflector::slug('Testing æ ø å'), 'Testing_ae_ø_aa');  | 
  
| 593 | 
      }  | 
  
| 594 | 
       | 
  
| 595 | 
      /**
     | 
  
| 596 | 
       * test that setting new rules clears the inflector caches.
     | 
  
| 597 | 
       *
     | 
  
| 598 | 
       * @return void
     | 
  
| 599 | 
       */
     | 
  
| 600 | 
      public function testRulesClearsCaches() {  | 
  
| 601 | 
      $this->assertEquals(Inflector::singularize('Bananas'), 'Banana');  | 
  
| 602 | 
      $this->assertEquals(Inflector::tableize('Banana'), 'bananas');  | 
  
| 603 | 
      $this->assertEquals(Inflector::pluralize('Banana'), 'Bananas');  | 
  
| 604 | 
       | 
  
| 605 | 
      Inflector::rules('singular', array(  | 
  
| 606 | 
      'rules' => array('/(.*)nas$/i' => '\1zzz')  | 
  
| 607 | 
      ));  | 
  
| 608 | 
      $this->assertEquals('Banazzz', Inflector::singularize('Bananas'), 'Was inflected with old rules.');  | 
  
| 609 | 
       | 
  
| 610 | 
      Inflector::rules('plural', array(  | 
  
| 611 | 
      'rules' => array('/(.*)na$/i' => '\1zzz'),  | 
  
| 612 | 
      'irregular' => array('corpus' => 'corpora')  | 
  
| 613 | 
      ));  | 
  
| 614 | 
      $this->assertEquals(Inflector::pluralize('Banana'), 'Banazzz', 'Was inflected with old rules.');  | 
  
| 615 | 
      $this->assertEquals(Inflector::pluralize('corpus'), 'corpora', 'Was inflected with old irregular form.');  | 
  
| 616 | 
      }  | 
  
| 617 | 
       | 
  
| 618 | 
      /**
     | 
  
| 619 | 
       * Test resetting inflection rules.
     | 
  
| 620 | 
       *
     | 
  
| 621 | 
       * @return void
     | 
  
| 622 | 
       */
     | 
  
| 623 | 
      public function testCustomRuleWithReset() {  | 
  
| 624 | 
      $uninflected = array('atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x');  | 
  
| 625 | 
      $pluralIrregular = array('as' => 'ases');  | 
  
| 626 | 
       | 
  
| 627 | 
      Inflector::rules('singular', array(  | 
  
| 628 | 
      'rules' => array('/^(.*)(a|e|o|u)is$/i' => '\1\2l'),  | 
  
| 629 | 
      'uninflected' => $uninflected,  | 
  
| 630 | 
                      ), true);
     | 
  
| 631 | 
       | 
  
| 632 | 
      Inflector::rules('plural', array(  | 
  
| 633 | 
      'rules' => array(  | 
  
| 634 | 
      '/^(.*)(a|e|o|u)l$/i' => '\1\2is',  | 
  
| 635 | 
      ),  | 
  
| 636 | 
      'uninflected' => $uninflected,  | 
  
| 637 | 
      'irregular' => $pluralIrregular  | 
  
| 638 | 
                      ), true);
     | 
  
| 639 | 
       | 
  
| 640 | 
      $this->assertEquals(Inflector::pluralize('Alcool'), 'Alcoois');  | 
  
| 641 | 
      $this->assertEquals(Inflector::pluralize('Atlas'), 'Atlas');  | 
  
| 642 | 
      $this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool');  | 
  
| 643 | 
      $this->assertEquals(Inflector::singularize('Atlas'), 'Atlas');  | 
  
| 644 | 
      }  | 
  
| 645 | 
       | 
  
| 646 | 
      }  |