Removing magical un-removable plugin concatenation in Controller::loadModel(). Adding test case from 'real34'. Fixes #858

This commit is contained in:
mark_story 2010-07-13 20:19:31 -04:00
parent fb9faf10f7
commit c9079c8048
2 changed files with 30 additions and 7 deletions

View file

@ -572,13 +572,7 @@ class Controller extends Object {
}
$cached = false;
$object = null;
$plugin = null;
if ($this->uses === false) {
if ($this->plugin) {
$plugin = $this->plugin . '.';
}
}
list($plugin, $modelClass) = pluginSplit($modelClass, true, $plugin);
list($plugin, $modelClass) = pluginSplit($modelClass, true);
if ($this->persistModel === true) {
$cached = $this->_persist($modelClass, null, $object);

View file

@ -461,6 +461,35 @@ class ControllerTest extends CakeTestCase {
unset($Controller);
}
/**
* testLoadModel method from a plugin controller
*
* @access public
* @return void
*/
function testLoadModelInPlugins() {
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)
));
App::import('Controller', 'TestPlugin.TestPlugin');
$Controller = new TestPluginController();
$Controller->plugin = 'TestPlugin';
$Controller->uses = false;
$this->assertFalse(isset($Controller->Comment));
$result = $Controller->loadModel('Comment');
$this->assertTrue($result);
$this->assertType('Comment', $Controller->Comment);
$this->assertTrue(in_array('Comment', $Controller->modelNames));
ClassRegistry::flush();
unset($Controller);
}
/**
* testConstructClasses method
*