Permalink
Browse files

Updating __mergeVars to correctly merge parent and child component co…

…nfigurations.

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
  • Loading branch information...
1 parent b68c78f commit c8cf1a2c5bed17c6c24df5484a957abf354bde3a @markstory markstory committed Apr 28, 2009
Showing with 17 additions and 1 deletion.
  1. +1 −1 cake/libs/controller/controller.php
  2. +16 −0 cake/tests/cases/libs/controller/controller.test.php
@@ -393,7 +393,7 @@ function __mergeVars() {
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 @@ function testMergeVars() {
$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

0 comments on commit c8cf1a2

Please sign in to comment.