Permalink
Browse files

Adding test for correct merge order for $uses.

Fixing incorrect merge ordering for $uses, so it matches historical behaviour.
Fixes #1309
  • Loading branch information...
markstory committed Nov 25, 2010
1 parent 1dfe2ac commit d91f7c2cd630b6c2e697b1f492437a6211001e94
Showing with 6 additions and 2 deletions.
  1. +2 −2 cake/libs/controller/controller.php
  2. +4 −0 cake/tests/cases/libs/controller/controller.test.php
@@ -399,7 +399,7 @@ function __mergeVars() {
$this->{$var} = Set::merge($app, $normal);
}
} else {
- $this->{$var} = Set::merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
+ $this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
}
}
}
@@ -423,7 +423,7 @@ function __mergeVars() {
$this->{$var} = Set::merge($app, $normal);
}
} else {
- $this->{$var} = Set::merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
+ $this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
}
}
}
@@ -937,6 +937,10 @@ function testMergeVars() {
$this->assertEqual(count(array_diff($TestController->uses, $uses)), 0);
$this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0);
+ $expected = array('ControllerComment', 'ControllerAlias', 'ControllerPost');
+ $this->assertEqual($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.');
+
+
$TestController =& new AnotherTestController();
$TestController->constructClasses();

0 comments on commit d91f7c2

Please sign in to comment.