mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
fixing issue with references from latest component refactor. test case added
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7088 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6c48154725
commit
09fae6203d
2 changed files with 28 additions and 12 deletions
|
@ -183,15 +183,15 @@ class Component extends Object {
|
|||
}
|
||||
}
|
||||
|
||||
if ($componentCn == 'SessionComponent') {
|
||||
$object->{$component} =& new $componentCn($base);
|
||||
if (isset($this->__loaded[$component])) {
|
||||
$object->{$component} =& $this->__loaded[$component];
|
||||
} else {
|
||||
$object->{$component} =& new $componentCn();
|
||||
}
|
||||
|
||||
$object->{$component}->enabled = true;
|
||||
|
||||
if (!isset($this->__loaded[$component])) {
|
||||
if ($componentCn == 'SessionComponent') {
|
||||
$object->{$component} =& new $componentCn($base);
|
||||
} else {
|
||||
$object->{$component} =& new $componentCn();
|
||||
}
|
||||
$object->{$component}->enabled = true;
|
||||
$this->__loaded[$component] =& $object->{$component};
|
||||
}
|
||||
|
||||
|
|
|
@ -41,10 +41,10 @@ class AppleComponent extends Object {
|
|||
|
||||
var $components = array('Orange');
|
||||
|
||||
var $name = null;
|
||||
var $testName = null;
|
||||
|
||||
function startup(&$controller) {
|
||||
$this->name = $controller->name;
|
||||
$this->testName = $controller->name;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,9 +52,14 @@ class OrangeComponent extends Object {
|
|||
|
||||
var $components = array('Banana');
|
||||
|
||||
function initialize(&$controller) {
|
||||
$this->Banana->testField = 'OrangeField';
|
||||
}
|
||||
}
|
||||
class BananaComponent extends Object {
|
||||
|
||||
var $testField = 'BananaField';
|
||||
|
||||
}
|
||||
|
||||
class ComponentTest extends CakeTestCase {
|
||||
|
@ -121,11 +126,22 @@ class ComponentTest extends CakeTestCase {
|
|||
$Controller->constructClasses();
|
||||
|
||||
$this->assertTrue(is_a($Controller->Apple, 'AppleComponent'));
|
||||
$this->assertEqual($Controller->Apple->name, null);
|
||||
$this->assertEqual($Controller->Apple->testName, null);
|
||||
|
||||
$Controller->Component->startup($Controller);
|
||||
|
||||
$this->assertEqual($Controller->Apple->name, 'ComponentTest');
|
||||
$this->assertEqual($Controller->Apple->testName, 'ComponentTest');
|
||||
}
|
||||
|
||||
function testMultipleComponentInitialize() {
|
||||
$Controller =& new ComponentTestController();
|
||||
$Controller->components = array('Orange', 'Banana');
|
||||
$Controller->constructClasses();
|
||||
|
||||
$Controller->Component->initialize($Controller);
|
||||
|
||||
$this->assertEqual($Controller->Banana->testField, 'OrangeField');
|
||||
$this->assertEqual($Controller->Orange->Banana->testField, 'OrangeField');
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue