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

This commit is contained in:
Mark Story 2010-04-21 22:49:48 -04:00
parent bb0ff192f7
commit 1d3b653e57

View file

@ -400,6 +400,27 @@ class InflectorTest extends CakeTestCase {
$this->assertEqual(Inflector::slug('Testing æ ø å', '-', array('/ø/' => 'oe')), 'Testing-ae-oe-aa');
}
/**
* 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.
*