Navigation Menu

Skip to content

Commit

Permalink
Adding test for correct merge order for $uses.
Browse files Browse the repository at this point in the history
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 d91f7c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cake/libs/controller/controller.php
Expand Up @@ -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}));
}
}
}
Expand All @@ -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}));
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions cake/tests/cases/libs/controller/controller.test.php
Expand Up @@ -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();

Expand Down

0 comments on commit d91f7c2

Please sign in to comment.