Browse files

Adding tests for custom singular rules to Inflector.

  • Loading branch information...
1 parent 6c1c6ad commit 0d8d8fa4014be9b5126643c68dbfd5a26aaabc48 @jperras jperras committed Mar 21, 2009
Showing with 24 additions and 0 deletions.
  1. +24 −0 cake/tests/cases/libs/inflector.test.php
View
24 cake/tests/cases/libs/inflector.test.php
@@ -271,6 +271,30 @@ function testCustomPluralRule() {
$this->assertEqual(Inflector::pluralize('phone'), 'phonezes');
}
/**
+ * testCustomSingularRule method
+ *
+ * @access public
+ * @return void
+ */
+ function testCustomSingularRule() {
+ Inflector::rules('singular', array('/(eple)r$/i' => '\1', '/(jente)r$/i' => '\1'));
+
+ $this->assertEqual(Inflector::singularize('epler'), 'eple');
+ $this->assertEqual(Inflector::singularize('jenter'), 'jente');
+
+ Inflector::rules('singular', array(
+ 'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'),
+ 'uninflected' => array('singulars'),
+ 'irregular' => array('spins' => 'spinor')
+ ));
+
+ $this->assertEqual(Inflector::singularize('inflectors'), 'inflecta');
+ $this->assertEqual(Inflector::singularize('contributors'), 'contributa');
+ $this->assertEqual(Inflector::singularize('spins'), 'spinor');
+ $this->assertEqual(Inflector::singularize('singulars'), 'singulars');
+ }
+
+/**
* tearDown method
*
* @access public

0 comments on commit 0d8d8fa

Please sign in to comment.