Permalink
Browse files

Adding test cases for Inflector::rule.

  • Loading branch information...
1 parent f811a69 commit 3853259f3f006180edec263d1d7a99da0bc7316b @jperras jperras committed Mar 18, 2009
Showing with 25 additions and 1 deletion.
  1. +25 −1 cake/tests/cases/libs/inflector.test.php
@@ -247,6 +247,30 @@ function testHumanization() {
$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
*
* @access public
@@ -256,4 +280,4 @@ function tearDown() {
unset($this->Inflector);
}
}
-?>
+?>

0 comments on commit 3853259

Please sign in to comment.