Skip to content

Commit

Permalink
Partially migrating EmailComponent test to phpunit, some tests need t…
Browse files Browse the repository at this point in the history
…o have installed a local smtp server
  • Loading branch information
lorenzo committed Jun 10, 2010
1 parent 22f1528 commit 42e02bf
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions cake/tests/cases/libs/controller/components/email.test.php
Expand Up @@ -76,6 +76,9 @@ function setHeaders($headers) {
* @return array
*/
function getHeaders() {
if (empty($this->_header)) {
return array();
}
return $this->__header;
}

Expand All @@ -96,6 +99,9 @@ function setBoundary() {
* @return string
*/
function getBoundary() {
if (empty($this->__boundary)) {
return null;
}
return $this->__boundary;
}

Expand All @@ -106,6 +112,9 @@ function getBoundary() {
* @return string
*/
function getMessage() {
if (empty($this->__message)) {
return array();
}
return $this->__message;
}

Expand Down Expand Up @@ -195,11 +204,9 @@ function setUp() {
$this->_appEncoding = Configure::read('App.encoding');
Configure::write('App.encoding', 'UTF-8');

$this->Controller =& new EmailTestController();
$this->Controller = new EmailTestController();

restore_error_handler();
@$this->Controller->Component->init($this->Controller);
set_error_handler('simpleTestErrorHandler');
$this->Controller->Component->init($this->Controller);

$this->Controller->EmailTest->initialize($this->Controller, array());
ClassRegistry::addObject('view', new View($this->Controller));
Expand All @@ -219,7 +226,6 @@ function tearDown() {
Configure::write('App.encoding', $this->_appEncoding);
App::build();
$this->Controller->Session->delete('Message');
restore_error_handler();
ClassRegistry::flush();
}

Expand Down Expand Up @@ -545,7 +551,7 @@ function testTemplates() {
function testSmtpSendSocket() {
$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost');

$socket =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions));
$socket = new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions));
$this->Controller->EmailTest->setConnectionSocket($socket);

$this->assertTrue($this->Controller->EmailTest->getConnectionSocket());
Expand Down Expand Up @@ -591,7 +597,7 @@ function testSendDebug() {
* @return void
*/
function testSendDebugWithNoSessions() {
$session =& $this->Controller->Session;
$session = $this->Controller->Session;
unset($this->Controller->Session);
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
Expand Down

0 comments on commit 42e02bf

Please sign in to comment.