Skip to content
Permalink
Browse files

Adding tests for custom singular rules to Inflector.

  • Loading branch information...
jperras committed Mar 22, 2009
1 parent 6c1c6ad commit 0d8d8fa4014be9b5126643c68dbfd5a26aaabc48
Showing with 24 additions and 0 deletions.
  1. +24 −0 cake/tests/cases/libs/inflector.test.php
@@ -270,6 +270,30 @@ function testCustomPluralRule() {
$this->assertEqual(Inflector::pluralize('amaze'), 'amazable');
$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
*

0 comments on commit 0d8d8fa

Please sign in to comment.
You can’t perform that action at this time.