Permalink
Browse files

Adding tests for Inflector::rules() clearing cached values. Fixes #609

  • Loading branch information...
1 parent bb0ff19 commit 1d3b653e578048c054fd48814ff22ddf4e63f6f2 @markstory markstory committed Apr 22, 2010
Showing with 21 additions and 0 deletions.
  1. +21 −0 cake/tests/cases/libs/inflector.test.php
@@ -401,6 +401,27 @@ function testCustomTransliterationRule() {
}
/**
+ * test that setting new rules clears the inflector caches.
+ *
+ * @return void
+ */
+ function testRulesClearsCaches() {
+ $this->assertEqual(Inflector::singularize('Bananas'), 'Banana');
+ $this->assertEqual(Inflector::tableize('Banana'), 'bananas');
+ $this->assertEqual(Inflector::pluralize('Banana'), 'Bananas');
+
+ Inflector::rules('singular', array(
+ 'rules' => array('/(.*)nas$/i' => '\1zzz')
+ ));
+ $this->assertEqual(Inflector::singularize('Bananas'), 'Banazzz', 'Was inflected with old rules. %s');
+
+ Inflector::rules('plural', array(
+ 'rules' => array('/(.*)na$/i' => '\1zzz')
+ ));
+ $this->assertEqual(Inflector::pluralize('Banana'), 'Banazzz', 'Was inflected with old rules. %s');
+ }
+
+/**
* Test resetting inflection rules.
*
* @return void

0 comments on commit 1d3b653

Please sign in to comment.