diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php index 2b28323c7..1db29bbdd 100644 --- a/cake/console/libs/acl.php +++ b/cake/console/libs/acl.php @@ -379,7 +379,7 @@ class AclShell extends Shell { * @access public */ function initdb() { - $this->Dispatch->args = array('schema', 'run', 'create', 'DbAcl'); + $this->Dispatch->args = array('schema', 'create', 'DbAcl'); $this->Dispatch->dispatch(); } diff --git a/cake/console/libs/tasks/test.php b/cake/console/libs/tasks/test.php index ff7996cde..9c7e3bc49 100644 --- a/cake/console/libs/tasks/test.php +++ b/cake/console/libs/tasks/test.php @@ -423,7 +423,7 @@ class TestTask extends BakeTask { */ function testCaseFileName($type, $className) { $path = $this->getPath();; - $path .= 'cases' . DS . Inflector::tableize($type) . DS; + $path .= 'cases' . DS . strtolower($type) . 's' . DS; if (strtolower($type) == 'controller') { $className = $this->getRealClassName($type, $className); } diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index 3c99bf9fd..1f1fd002c 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -370,6 +370,11 @@ class Inflector { $_this->{$var}[$rule] = array_merge($pattern, $_this->{$var}[$rule]); } unset($rules[$rule], $_this->{$var}['cache' . ucfirst($rule)], $_this->{$var}['merged'][$rule]); + if ($type === 'plural') { + $_this->_pluralized = $_this->_tableize = array(); + } elseif ($type === 'singular') { + $_this->_singularized = array(); + } } } $_this->{$var}['rules'] = array_merge($rules, $_this->{$var}['rules']); diff --git a/cake/tests/cases/console/libs/acl.test.php b/cake/tests/cases/console/libs/acl.test.php index ccd3d0401..02aba2c7a 100644 --- a/cake/tests/cases/console/libs/acl.test.php +++ b/cake/tests/cases/console/libs/acl.test.php @@ -36,7 +36,7 @@ if (!class_exists('AclShell')) { Mock::generatePartial( 'ShellDispatcher', 'TestAclShellMockShellDispatcher', - array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment') + array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'dispatch') ); Mock::generatePartial( 'AclShell', 'MockAclShell', @@ -331,5 +331,17 @@ class AclShellTest extends CakeTestCase { $this->Task->expectAt(3, 'out', array(' [4] Elrond')); $this->Task->getPath(); } + +/** + * test that initdb makes the correct call. + * + * @return void + */ + function testInitDb() { + $this->Task->Dispatch->expectOnce('dispatch'); + $this->Task->initdb(); + + $this->assertEqual($this->Task->Dispatch->args, array('schema', 'create', 'DbAcl')); + } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php index 7e38fea77..e8aa61597 100644 --- a/cake/tests/cases/libs/inflector.test.php +++ b/cake/tests/cases/libs/inflector.test.php @@ -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. *