mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing modelClass when using plugin models.
Added TestPluginPost to test_app/test_plugin Test case added. Closes #5459 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7641 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
d9b357d05c
commit
fafb01b09d
3 changed files with 63 additions and 1 deletions
|
@ -394,7 +394,11 @@ class Controller extends Object {
|
|||
$this->loadModel($this->modelClass, $id);
|
||||
} elseif ($this->uses) {
|
||||
$uses = is_array($this->uses) ? $this->uses : array($this->uses);
|
||||
$this->modelClass = $uses[0];
|
||||
$modelClassName = $uses[0];
|
||||
if (strpos($uses[0], '.') !== false) {
|
||||
list($plugin, $modelClassName) = explode('.', $uses[0]);
|
||||
}
|
||||
$this->modelClass = $modelClassName;
|
||||
foreach ($uses as $modelClass) {
|
||||
$this->loadModel($modelClass);
|
||||
}
|
||||
|
|
|
@ -318,6 +318,22 @@ class ControllerTest extends CakeTestCase {
|
|||
$this->assertEqual($Controller->ControllerComment->name, 'Comment');
|
||||
|
||||
unset($Controller);
|
||||
|
||||
$_back = array(
|
||||
'pluginPaths' => Configure::read('pluginPaths'),
|
||||
);
|
||||
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
|
||||
|
||||
$Controller =& new Controller();
|
||||
$Controller->uses = array('TestPlugin.TestPluginPost');
|
||||
$Controller->constructClasses();
|
||||
|
||||
$this->assertEqual($Controller->modelClass, 'TestPluginPost');
|
||||
$this->assertTrue(isset($Controller->TestPluginPost));
|
||||
$this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost'));
|
||||
|
||||
Configure::write('pluginPaths', $_back['pluginPaths']);
|
||||
unset($Controller);
|
||||
}
|
||||
|
||||
function testAliasName() {
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Test Plugin Post Model
|
||||
*
|
||||
*
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.tests.test_app.plugins.test_plugin
|
||||
* @since CakePHP v 1.2.0.4487
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
class TestPluginPost extends TestPluginAppModel {
|
||||
/**
|
||||
* Name property
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $name = 'Post';
|
||||
/**
|
||||
* useTable property
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
var $useTable = 'posts';
|
||||
}
|
Loading…
Reference in a new issue