@@ -181,6 +181,7 @@ class OrangeComponent extends Object {
181
181
* @return void
182
182
*/
183
183
function initialize (&$ controller , $ settings ) {
184
+ $ this ->Controller = $ controller ;
184
185
$ this ->Banana ->testField = 'OrangeField ' ;
185
186
$ this ->settings = $ settings ;
186
187
}
@@ -226,6 +227,16 @@ class MutuallyReferencingOneComponent extends Object {
226
227
class MutuallyReferencingTwoComponent extends Object {
227
228
var $ components = array ('MutuallyReferencingOne ' );
228
229
}
230
+
231
+ /**
232
+ * SomethingWithEmailComponent class
233
+ *
234
+ * @package cake
235
+ * @subpackage cake.tests.cases.libs.controller
236
+ */
237
+ class SomethingWithEmailComponent extends Object {
238
+ var $ components = array ('Email ' );
239
+ }
229
240
/**
230
241
* ComponentTest class
231
242
*
@@ -308,6 +319,8 @@ function testNestedComponentLoading() {
308
319
$ this ->assertTrue (is_a ($ Controller ->Apple , 'AppleComponent ' ));
309
320
$ this ->assertTrue (is_a ($ Controller ->Apple ->Orange , 'OrangeComponent ' ));
310
321
$ this ->assertTrue (is_a ($ Controller ->Apple ->Orange ->Banana , 'BananaComponent ' ));
322
+ $ this ->assertTrue (is_a ($ Controller ->Apple ->Orange ->Controller , 'ComponentTestController ' ));
323
+
311
324
}
312
325
/**
313
326
* Tests Component::startup() and only running callbacks for components directly attached to
@@ -404,6 +417,32 @@ function testMutuallyReferencingComponents() {
404
417
'MutuallyReferencingOneComponent '
405
418
));
406
419
}
420
+ /**
421
+ * Test mutually referencing components.
422
+ *
423
+ * @return void
424
+ */
425
+ function testSomethingReferencingEmailComponent () {
426
+ $ Controller =& new ComponentTestController ();
427
+ $ Controller ->components = array ('SomethingWithEmail ' );
428
+ $ Controller ->constructClasses ();
429
+ $ Controller ->Component ->initialize ($ Controller );
430
+ $ Controller ->beforeFilter ();
431
+ $ Controller ->Component ->startup ($ Controller );
432
+
433
+ $ this ->assertTrue (is_a (
434
+ $ Controller ->SomethingWithEmail ,
435
+ 'SomethingWithEmailComponent '
436
+ ));
437
+ $ this ->assertTrue (is_a (
438
+ $ Controller ->SomethingWithEmail ->Email ,
439
+ 'EmailComponent '
440
+ ));
441
+ $ this ->assertTrue (is_a (
442
+ $ Controller ->SomethingWithEmail ->Email ->Controller ,
443
+ 'ComponentTestController '
444
+ ));
445
+ }
407
446
}
408
447
409
448
?>
0 commit comments