Skip to content

Commit

Permalink
Removing magical un-removable plugin concatenation in Controller::loa…
Browse files Browse the repository at this point in the history
…dModel(). Adding test case from 'real34'. Fixes #858
  • Loading branch information
markstory committed Jul 14, 2010
1 parent fb9faf1 commit c9079c8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
8 changes: 1 addition & 7 deletions cake/libs/controller/controller.php
Expand Up @@ -572,13 +572,7 @@ public function loadModel($modelClass = null, $id = null) {
}
$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);
Expand Down
29 changes: 29 additions & 0 deletions cake/tests/cases/libs/controller/controller.test.php
Expand Up @@ -461,6 +461,35 @@ function testLoadModel() {
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
*
Expand Down

0 comments on commit c9079c8

Please sign in to comment.