From a9a31384edef2d1e98741659af3959346fbbd35d Mon Sep 17 00:00:00 2001 From: jperras Date: Sun, 9 Aug 2009 22:20:22 -0400 Subject: [PATCH] Cleaning up tests for EmailComponent --- cake/libs/controller/components/email.php | 2 ++ .../libs/controller/components/email.test.php | 22 ++----------------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 640611f68..8db79468a 100644 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -325,11 +325,13 @@ class EmailComponent extends Object{ } $message = $this->_wrap($content); + if ($this->template === null) { $message = $this->_formatMessage($message); } else { $message = $this->_render($message); } + $message[] = ''; $this->__message = $message; diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index b4bedd164..2c60027b0 100644 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -262,7 +262,7 @@ class EmailComponentTest extends CakeTestCase { if (!$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) { return; } - $this->Controller->EmailTest->reset(); + $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; @@ -310,7 +310,6 @@ TEMPDOC; function testAuthenticatedSmtpSend() { $this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost'); - $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; @@ -335,7 +334,6 @@ TEMPDOC; * @return void */ function testSendFormats() { - $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; @@ -386,7 +384,6 @@ MSGBLOC; * @return void */ function testTemplates() { - $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'Cake SMTP test'; @@ -507,7 +504,6 @@ TEXTBLOC; function testSmtpSendSocket() { $this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost'); - $this->Controller->EmailTest->reset(); $socket =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions)); $this->Controller->EmailTest->setConnectionSocket($socket); @@ -529,7 +525,6 @@ TEXTBLOC; * @return void */ function testSendDebug() { - $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; @@ -558,7 +553,6 @@ TEXTBLOC; * @return void */ function testSendContentArray() { - $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'Cake Debug Test'; @@ -617,7 +611,6 @@ TEXTBLOC; * @return void */ function testMultibyte() { - $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'هذه رسالة بعنوان طويل مرسل للمستلم'; @@ -650,7 +643,6 @@ TEXTBLOC; * @access public */ function testSendAsIsNotIgnoredIfAttachmentsPresent() { - $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'Attachment Test'; @@ -688,7 +680,6 @@ TEXTBLOC; * @access public */ function testNoDoubleNewlinesInHeaders() { - $this->Controller->EmailTest->reset(); $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'Attachment Test'; @@ -745,34 +736,25 @@ TEXTBLOC; $this->assertIdentical($this->Controller->EmailTest->attachments, array()); } - function testCustomViewClass() { + function testPluginCustomViewClass() { App::build(array( 'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS), 'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS) )); - $this->Controller->EmailTest->reset(); - $this->Controller->view = 'TestPlugin.Email'; $this->Controller->EmailTest->to = 'postmaster@localhost'; $this->Controller->EmailTest->from = 'noreply@example.com'; $this->Controller->EmailTest->subject = 'CustomViewClass test'; - $this->Controller->EmailTest->replyTo = 'noreply@example.com'; - - $this->Controller->EmailTest->template = 'default'; - $this->Controller->EmailTest->layout = 'default'; - $this->Controller->EmailTest->delivery = 'debug'; $body = 'Body of message'; - $this->Controller->EmailTest->sendAs = 'text'; $this->assertTrue($this->Controller->EmailTest->send($body)); $result = $this->Controller->Session->read('Message.email.message'); $this->assertPattern('/Body of message/', $result); - debug($result, true); } /**