Fixing more tests that were failing post merge.

This commit is contained in:
mark_story 2010-12-10 23:17:42 -05:00
parent 1e108748e9
commit ceca179184
3 changed files with 17 additions and 8 deletions

View file

@ -440,17 +440,24 @@ class Controller extends Object {
$this->uses = array_flip($this->uses);
array_unshift($this->uses, $plugin . $this->modelClass);
}
} elseif ($this->uses !== null || $this->uses !== false) {
$this->_mergeVars(array('uses'), 'AppController', false);
} elseif (
($this->uses !== null || $this->uses !== false) &&
is_array($this->uses) && !empty($appVars['uses'])
) {
$this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses));
var_dump($this->uses);
}
$this->_mergeVars($merge, 'AppController', true);
}
if ($pluginController && $pluginName != null) {
$merge = array('components', 'helpers');
if ($this->uses !== null || $this->uses !== false) {
$this->_mergeVars(array('uses'), $pluginController, false);
$appVars = get_class_vars($pluginController);
if (
($this->uses !== null || $this->uses !== false) &&
is_array($this->uses) && !empty($appVars['uses'])
) {
$this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses));
}
$this->_mergeVars($merge, $pluginController);
}

View file

@ -1283,13 +1283,14 @@ class ControllerTest extends CakeTestCase {
? array_merge($appVars['uses'], $testVars['uses'])
: $testVars['uses'];
$this->assertEqual(count(array_diff($TestController->helpers, $helpers)), 0);
$this->assertEqual(count(array_diff_key($TestController->helpers, array_flip($helpers))), 0);
$this->assertEqual(count(array_diff($TestController->uses, $uses)), 0);
$this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0);
$TestController = new AnotherTestController($request);
$expected = array('ControllerComment', 'ControllerAlias', 'ControllerPost');
$this->assertEqual($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.');
$this->assertEquals($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.');
$TestController = new AnotherTestController($request);
$TestController->constructClasses();
$appVars = get_class_vars('AppController');

View file

@ -18,6 +18,7 @@
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
App::import('Helper', 'Number');
App::import('View', 'View');
/**
* NumberHelperTest class