Skip to content

Commit

Permalink
EmailComponent:: now is set to null after calling EmailComponent::res…
Browse files Browse the repository at this point in the history
…et(). Test cases added; fixes #6314.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8153 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
jperras committed Apr 25, 2009
1 parent 650d1e7 commit 97abf84
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions cake/libs/controller/components/email.php
Expand Up @@ -345,6 +345,7 @@ function reset() {
$this->bcc = array(); $this->bcc = array();
$this->subject = null; $this->subject = null;
$this->additionalParams = null; $this->additionalParams = null;
$this->smtpError = null;
$this->__header = array(); $this->__header = array();
$this->__boundary = null; $this->__boundary = null;
$this->__message = array(); $this->__message = array();
Expand Down
82 changes: 82 additions & 0 deletions cake/tests/cases/libs/controller/components/email.test.php
Expand Up @@ -59,6 +59,51 @@ function setConnectionSocket(&$socket) {
function getConnectionSocket() { function getConnectionSocket() {
return $this->__smtpConnection; 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 * EmailTestController class
Expand Down Expand Up @@ -490,6 +535,43 @@ function testMultibyte() {
preg_match('/Subject: (.*)Header:/s', $this->Controller->Session->read('Message.email.message'), $matches); preg_match('/Subject: (.*)Header:/s', $this->Controller->Session->read('Message.email.message'), $matches);
$this->assertEqual(trim($matches[1]), $subject); $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 * osFix method
* *
Expand Down

0 comments on commit 97abf84

Please sign in to comment.