diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 0b7050d71..bd20d82bd 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -866,7 +866,7 @@ class Controller extends Object { if (!empty($this->uses)) { foreach ($this->uses as $model) { list($plugin, $className) = pluginSplit($model); - $this->request->params['models'][$model] = compact('plugin', 'className'); + $this->request->params['models'][$className] = compact('plugin', 'className'); } } if (!empty($this->modelClass) && ($this->uses === false || $this->uses === array())) { $this->request->params['models'][$this->modelClass] = array('plugin' => $this->plugin, 'className' => $this->modelClass); diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index ad1f5a3d1..31d451de2 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -651,6 +651,7 @@ class ControllerTest extends CakeTestCase { $Controller->view = null; $Controller = new TestController($request, new CakeResponse()); + $Controller->uses = array('ControllerAlias', 'TestPlugin.ControllerComment', 'ControllerPost'); $Controller->helpers = array('Html'); $Controller->constructClasses(); $Controller->ControllerComment->validationErrors = array('title' => 'tooShort'); @@ -664,15 +665,12 @@ class ControllerTest extends CakeTestCase { $expectedModels = array( 'ControllerAlias' => array('plugin' => null, 'className' => 'ControllerAlias'), - 'ControllerComment' => array('plugin' => null, 'className' => 'ControllerComment'), + 'ControllerComment' => array('plugin' => 'TestPlugin', 'className' => 'ControllerComment'), 'ControllerPost' => array('plugin' => null, 'className' => 'ControllerPost') ); $this->assertEqual($expectedModels, $Controller->request->params['models']); - - $Controller->ControllerComment->validationErrors = array(); ClassRegistry::flush(); - App::build(); }