Changing how merged rules are cleared so it doesn't generated notice errors in PHP4. Test added. Fixes #762

This commit is contained in:
mark_story 2010-06-01 23:41:51 -04:00
parent 8d8fce4429
commit 7682c5896e
2 changed files with 19 additions and 21 deletions

View file

@ -369,7 +369,10 @@ class Inflector {
} else { } else {
$_this->{$var}[$rule] = array_merge($pattern, $_this->{$var}[$rule]); $_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') { if ($type === 'plural') {
$_this->_pluralized = $_this->_tableize = array(); $_this->_pluralized = $_this->_tableize = array();
} elseif ($type === 'singular') { } elseif ($type === 'singular') {

View file

@ -42,16 +42,6 @@ class InflectorTest extends CakeTestCase {
*/ */
var $Inflector = null; var $Inflector = null;
/**
* setUp method
*
* @access public
* @return void
*/
function setUp() {
$this->Inflector = Inflector::getInstance();
}
/** /**
* testInstantiation method * testInstantiation method
* *
@ -59,7 +49,8 @@ class InflectorTest extends CakeTestCase {
* @return void * @return void
*/ */
function testInstantiation() { 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->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 * testCustomPluralRule method
* *
@ -455,13 +459,4 @@ class InflectorTest extends CakeTestCase {
$this->assertEqual(Inflector::singularize('Atlas'), 'Atlas'); $this->assertEqual(Inflector::singularize('Atlas'), 'Atlas');
} }
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Inflector);
}
} }