Skip to content
This repository
Browse code

fixes #5904, changing email component to use initialize instead of st…

…artup, so it can be used in other components more easily

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7969 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit 4f0256f9cdcc0ce9c617a314e383c003eef91d4b 1 parent 7421729
authored January 02, 2009
3  cake/libs/controller/components/email.php
@@ -262,11 +262,12 @@ class EmailComponent extends Object{
262 262
  * @param object $controller Instantiating controller
263 263
  * @access public
264 264
  */
265  
-	function startup(&$controller) {
  265
+	function initialize(&$controller, $settings) {
266 266
 		$this->Controller =& $controller;
267 267
 		if (Configure::read('App.encoding') !== null) {
268 268
 			$this->charset = Configure::read('App.encoding');
269 269
 		}
  270
+		$this->_set($settings);
270 271
 	}
271 272
 /**
272 273
  * Send an email using the specified content, template and layout
39  cake/tests/cases/libs/controller/component.test.php
@@ -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 notes on commit 4f0256f

Please sign in to comment.
Something went wrong with that request. Please try again.