Skip to content
Permalink
Browse files

Changing how merged rules are cleared so it doesn't generated notice …

…errors in PHP4. Test added. Fixes #762
  • Loading branch information...
markstory committed Jun 2, 2010
1 parent 8d8fce4 commit 7682c5896e269797741417c5d40db2f5024d387f
Showing with 19 additions and 21 deletions.
  1. +4 −1 cake/libs/inflector.php
  2. +15 −20 cake/tests/cases/libs/inflector.test.php
@@ -369,7 +369,10 @@ function rules($type, $rules, $reset = false) {
} 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') {
@@ -42,24 +42,15 @@ class InflectorTest extends CakeTestCase {
*/
var $Inflector = null;
/**
* setUp method
*
* @access public
* @return void
*/
function setUp() {
$this->Inflector = Inflector::getInstance();
}
/**
* testInstantiation method
*
* @access public
* @return void
*/
function testInstantiation() {
$this->assertEqual(Inflector::getInstance(), $this->Inflector);
$Inflector =& Inflector::getInstance();
$this->assertEqual(Inflector::getInstance(), $Inflector);
}
/**
@@ -339,6 +330,19 @@ function testHumanization() {
$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 @@ function testCustomRuleWithReset() {
$this->assertEqual(Inflector::singularize('Atlas'), 'Atlas');
}
/**
* tearDown method
*
* @access public
* @return void
*/
function tearDown() {
unset($this->Inflector);
}
}

0 comments on commit 7682c58

Please sign in to comment.
You can’t perform that action at this time.