diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index 46fc540be..dc0f78f6b 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -369,7 +369,10 @@ class Inflector { } else { $_this->{$var}[$rule] = array_merge($pattern, $_this->{$var}[$rule]); } - unset($rules[$rule], $_this->{$var}['cache' . ucfirst($rule)], $_this->{$var}['merged'][$rule]); + unset($rules[$rule], $_this->{$var}['cache' . ucfirst($rule)]); + if (isset($_this->{$var}['merged'][$rule])) { + unset($_this->{$var}['merged'][$rule]); + } if ($type === 'plural') { $_this->_pluralized = $_this->_tableize = array(); } elseif ($type === 'singular') { diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php index c894e8a65..519b39978 100644 --- a/cake/tests/cases/libs/inflector.test.php +++ b/cake/tests/cases/libs/inflector.test.php @@ -42,16 +42,6 @@ class InflectorTest extends CakeTestCase { */ var $Inflector = null; -/** - * setUp method - * - * @access public - * @return void - */ - function setUp() { - $this->Inflector = Inflector::getInstance(); - } - /** * testInstantiation method * @@ -59,7 +49,8 @@ class InflectorTest extends CakeTestCase { * @return void */ function testInstantiation() { - $this->assertEqual(Inflector::getInstance(), $this->Inflector); + $Inflector =& Inflector::getInstance(); + $this->assertEqual(Inflector::getInstance(), $Inflector); } /** @@ -339,6 +330,19 @@ class InflectorTest extends CakeTestCase { $this->assertEqual(Inflector::humanize('file_systems'), 'File Systems'); } +/** + * This test if run in isolation should not cause errors in PHP4. + * + * @return void + */ + function testRulesNoErrorPHP4() { + Inflector::rules('plural', array( + 'rules' => array(), + 'irregular' => array(), + 'uninflected' => array('pays') + )); + } + /** * testCustomPluralRule method * @@ -455,13 +459,4 @@ class InflectorTest extends CakeTestCase { $this->assertEqual(Inflector::singularize('Atlas'), 'Atlas'); } -/** - * tearDown method - * - * @access public - * @return void - */ - function tearDown() { - unset($this->Inflector); - } }