Permalink
Browse files

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...
1 parent 7421729 commit 4f0256f9cdcc0ce9c617a314e383c003eef91d4b gwoo committed Jan 2, 2009
Showing with 41 additions and 1 deletion.
  1. +2 −1 cake/libs/controller/components/email.php
  2. +39 −0 cake/tests/cases/libs/controller/component.test.php
@@ -262,11 +262,12 @@ class EmailComponent extends Object{
* @param object $controller Instantiating controller
* @access public
*/
- function startup(&$controller) {
+ function initialize(&$controller, $settings) {
$this->Controller =& $controller;
if (Configure::read('App.encoding') !== null) {
$this->charset = Configure::read('App.encoding');
}
+ $this->_set($settings);
}
/**
* Send an email using the specified content, template and layout
@@ -181,6 +181,7 @@ class OrangeComponent extends Object {
* @return void
*/
function initialize(&$controller, $settings) {
+ $this->Controller = $controller;
$this->Banana->testField = 'OrangeField';
$this->settings = $settings;
}
@@ -226,6 +227,16 @@ class MutuallyReferencingOneComponent extends Object {
class MutuallyReferencingTwoComponent extends Object {
var $components = array('MutuallyReferencingOne');
}
+
+/**
+ * SomethingWithEmailComponent class
+ *
+ * @package cake
+ * @subpackage cake.tests.cases.libs.controller
+ */
+class SomethingWithEmailComponent extends Object {
+ var $components = array('Email');
+}
/**
* ComponentTest class
*
@@ -308,6 +319,8 @@ function testNestedComponentLoading() {
$this->assertTrue(is_a($Controller->Apple, 'AppleComponent'));
$this->assertTrue(is_a($Controller->Apple->Orange, 'OrangeComponent'));
$this->assertTrue(is_a($Controller->Apple->Orange->Banana, 'BananaComponent'));
+ $this->assertTrue(is_a($Controller->Apple->Orange->Controller, 'ComponentTestController'));
+
}
/**
* Tests Component::startup() and only running callbacks for components directly attached to
@@ -404,6 +417,32 @@ function testMutuallyReferencingComponents() {
'MutuallyReferencingOneComponent'
));
}
+/**
+ * Test mutually referencing components.
+ *
+ * @return void
+ */
+ function testSomethingReferencingEmailComponent() {
+ $Controller =& new ComponentTestController();
+ $Controller->components = array('SomethingWithEmail');
+ $Controller->constructClasses();
+ $Controller->Component->initialize($Controller);
+ $Controller->beforeFilter();
+ $Controller->Component->startup($Controller);
+
+ $this->assertTrue(is_a(
+ $Controller->SomethingWithEmail,
+ 'SomethingWithEmailComponent'
+ ));
+ $this->assertTrue(is_a(
+ $Controller->SomethingWithEmail->Email,
+ 'EmailComponent'
+ ));
+ $this->assertTrue(is_a(
+ $Controller->SomethingWithEmail->Email->Controller,
+ 'ComponentTestController'
+ ));
+ }
}
?>

0 comments on commit 4f0256f

Please sign in to comment.