Skip to content

Commit

Permalink
Adding test cases for Inflector::rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
jperras committed Mar 18, 2009
1 parent f811a69 commit 3853259
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion cake/tests/cases/libs/inflector.test.php
Expand Up @@ -246,6 +246,30 @@ function testHumanization() {
$this->assertEqual(Inflector::humanize('posts_tags'), 'Posts Tags'); $this->assertEqual(Inflector::humanize('posts_tags'), 'Posts Tags');
$this->assertEqual(Inflector::humanize('file_systems'), 'File Systems'); $this->assertEqual(Inflector::humanize('file_systems'), 'File Systems');
} }
/**
* testCustomPluralRule method
*
* @access public
* @return void
*/
function testCustomPluralRule() {
Inflector::rules('plural', array('/^(custom)$/i' => '\1izables'));
$this->assertEqual(Inflector::pluralize('custom'), 'customizables');

Inflector::rules('plural', array('uninflected' => array('uninflectable')));
$this->assertEqual(Inflector::pluralize('uninflectable'), 'uninflectable');

Inflector::rules('plural', array(
'rules' => array('/^(alert)$/i' => '\1ables'),
'uninflected' => array('noflect', 'abtuse'),
'irregular' => array('amaze' => 'amazable', 'phone' => 'phonezes')
));
$this->assertEqual(Inflector::pluralize('noflect'), 'noflect');
$this->assertEqual(Inflector::pluralize('abtuse'), 'abtuse');
$this->assertEqual(Inflector::pluralize('alert'), 'alertables');
$this->assertEqual(Inflector::pluralize('amaze'), 'amazable');
$this->assertEqual(Inflector::pluralize('phone'), 'phonezes');
}
/** /**
* tearDown method * tearDown method
* *
Expand All @@ -256,4 +280,4 @@ function tearDown() {
unset($this->Inflector); unset($this->Inflector);
} }
} }
?> ?>

0 comments on commit 3853259

Please sign in to comment.