mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Removing magical un-removable plugin concatenation in Controller::loadModel(). Adding test case from 'real34'. Fixes #858
This commit is contained in:
parent
fb9faf10f7
commit
c9079c8048
2 changed files with 30 additions and 7 deletions
|
@ -572,13 +572,7 @@ class Controller extends Object {
|
||||||
}
|
}
|
||||||
$cached = false;
|
$cached = false;
|
||||||
$object = null;
|
$object = null;
|
||||||
$plugin = null;
|
list($plugin, $modelClass) = pluginSplit($modelClass, true);
|
||||||
if ($this->uses === false) {
|
|
||||||
if ($this->plugin) {
|
|
||||||
$plugin = $this->plugin . '.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list($plugin, $modelClass) = pluginSplit($modelClass, true, $plugin);
|
|
||||||
|
|
||||||
if ($this->persistModel === true) {
|
if ($this->persistModel === true) {
|
||||||
$cached = $this->_persist($modelClass, null, $object);
|
$cached = $this->_persist($modelClass, null, $object);
|
||||||
|
|
|
@ -461,6 +461,35 @@ class ControllerTest extends CakeTestCase {
|
||||||
unset($Controller);
|
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
|
* testConstructClasses method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue