Adding test for correct merge order for $uses.

Fixing incorrect merge ordering for $uses, so it matches historical behaviour.
Fixes #1309
This commit is contained in:
mark_story 2010-11-24 22:44:12 -05:00
parent 0e29567f8d
commit 4214242efd
2 changed files with 6 additions and 6 deletions

View file

@ -437,9 +437,7 @@ class Controller extends Object {
$this->{$var} = Set::merge($app, $normal);
}
} else {
$this->{$var} = Set::merge(
array_diff($appVars[$var], $this->{$var}), $this->{$var}
);
$this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
}
}
}
@ -463,9 +461,7 @@ class Controller extends Object {
$this->{$var} = Set::merge($app, $normal);
}
} else {
$this->{$var} = Set::merge(
array_diff($appVars[$var], $this->{$var}), $this->{$var}
);
$this->{$var} = array_merge($this->{$var}, array_diff($appVars[$var], $this->{$var}));
}
}
}

View file

@ -1153,6 +1153,10 @@ class ControllerTest extends CakeTestCase {
$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();