mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Updating __mergeVars to correctly merge parent and child component configurations.
Applied patch from 'neilcrookes'. Test case added. Fixes #6325 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8157 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
b68c78fc0f
commit
c8cf1a2c5b
2 changed files with 17 additions and 1 deletions
|
@ -393,7 +393,7 @@ class Controller extends Object {
|
|||
if ($var === 'components') {
|
||||
$normal = Set::normalize($this->{$var});
|
||||
$app = Set::normalize($appVars[$var]);
|
||||
$this->{$var} = Set::merge($normal, $app);
|
||||
$this->{$var} = Set::merge($app, $normal);
|
||||
} else {
|
||||
$this->{$var} = Set::merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
|
||||
}
|
||||
|
|
|
@ -940,6 +940,22 @@ class ControllerTest extends CakeTestCase {
|
|||
$this->assertTrue(isset($TestController->ControllerPost));
|
||||
$this->assertTrue(isset($TestController->ControllerComment));
|
||||
}
|
||||
/**
|
||||
* test that options from child classes replace those in the parent classes.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
**/
|
||||
function testChildComponentOptionsSupercedeParents() {
|
||||
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
|
||||
return;
|
||||
}
|
||||
$TestController =& new TestController();
|
||||
$expected = array('foo');
|
||||
$TestController->components = array('Cookie' => $expected);
|
||||
$TestController->constructClasses();
|
||||
$this->assertEqual($TestController->components['Cookie'], $expected);
|
||||
}
|
||||
/**
|
||||
* Ensure that __mergeVars is not being greedy and merging with
|
||||
* AppController when you make an instance of Controller
|
||||
|
|
Loading…
Reference in a new issue