From 97abf8477096fe5afae3319bab0ba5a916be217e Mon Sep 17 00:00:00 2001 From: jperras Date: Sat, 25 Apr 2009 00:01:57 +0000 Subject: [PATCH] EmailComponent:: now is set to null after calling EmailComponent::reset(). Test cases added; fixes #6314. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8153 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/controller/components/email.php | 1 + .../libs/controller/components/email.test.php | 82 +++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/cake/libs/controller/components/email.php b/cake/libs/controller/components/email.php index 71b013a1473..90dc72055be 100644 --- a/cake/libs/controller/components/email.php +++ b/cake/libs/controller/components/email.php @@ -345,6 +345,7 @@ function reset() { $this->bcc = array(); $this->subject = null; $this->additionalParams = null; + $this->smtpError = null; $this->__header = array(); $this->__boundary = null; $this->__message = array(); diff --git a/cake/tests/cases/libs/controller/components/email.test.php b/cake/tests/cases/libs/controller/components/email.test.php index 4258c952c98..08f033aacac 100644 --- a/cake/tests/cases/libs/controller/components/email.test.php +++ b/cake/tests/cases/libs/controller/components/email.test.php @@ -59,6 +59,51 @@ function setConnectionSocket(&$socket) { function getConnectionSocket() { return $this->__smtpConnection; } +/** + * Convenience setter for testing. + * + * @access public + * @return void + */ + function setHeaders($headers) { + $this->__header += $headers; + } +/** + * Convenience getter for testing. + * + * @access public + * @return array + */ + function getHeaders() { + return $this->__header; + } +/** + * Convenience setter for testing. + * + * @access public + * @return void + */ + function setBoundary() { + $this->__createBoundary(); + } +/** + * Convenience getter for testing. + * + * @access public + * @return string + */ + function getBoundary() { + return $this->__boundary; + } +/** + * Convenience getter for testing. + * + * @access public + * @return string + */ + function getMessage() { + return $this->__message; + } } /** * EmailTestController class @@ -490,6 +535,43 @@ function testMultibyte() { preg_match('/Subject: (.*)Header:/s', $this->Controller->Session->read('Message.email.message'), $matches); $this->assertEqual(trim($matches[1]), $subject); } +/** + * testReset method + * + * @access public + * @return void + */ + function testReset() { + $this->Controller->EmailTest->template = 'test_template'; + $this->Controller->EmailTest->to = 'test.recipient@example.com'; + $this->Controller->EmailTest->from = 'test.sender@example.com'; + $this->Controller->EmailTest->replyTo = 'test.replyto@example.com'; + $this->Controller->EmailTest->return = 'test.return@example.com'; + $this->Controller->EmailTest->cc = array('cc1@example.com', 'cc2@example.com'); + $this->Controller->EmailTest->bcc = array('bcc1@example.com', 'bcc2@example.com'); + $this->Controller->EmailTest->subject = 'Test subject'; + $this->Controller->EmailTest->additionalParams = 'X-additional-header'; + $this->Controller->EmailTest->delivery = 'smtp'; + $this->Controller->EmailTest->smtpOptions['host'] = 'blah'; + + $this->assertFalse($this->Controller->EmailTest->send('Should not work')); + + $this->Controller->EmailTest->reset(); + + $this->assertNull($this->Controller->EmailTest->template); + $this->assertNull($this->Controller->EmailTest->to); + $this->assertNull($this->Controller->EmailTest->from); + $this->assertNull($this->Controller->EmailTest->replyTo); + $this->assertNull($this->Controller->EmailTest->return); + $this->assertIdentical($this->Controller->EmailTest->cc, array()); + $this->assertIdentical($this->Controller->EmailTest->bcc, array()); + $this->assertNull($this->Controller->EmailTest->subject); + $this->assertNull($this->Controller->EmailTest->additionalParams); + $this->assertIdentical($this->Controller->EmailTest->getHeaders(), array()); + $this->assertNull($this->Controller->EmailTest->getBoundary()); + $this->assertIdentical($this->Controller->EmailTest->getMessage(), array()); + $this->assertNull($this->Controller->EmailTest->smtpError); + } /** * osFix method *