Skip to content

Commit 42e02bf

Browse files
committed
Partially migrating EmailComponent test to phpunit, some tests need to have installed a local smtp server
1 parent 22f1528 commit 42e02bf

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

cake/tests/cases/libs/controller/components/email.test.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ function setHeaders($headers) {
7676
* @return array
7777
*/
7878
function getHeaders() {
79+
if (empty($this->_header)) {
80+
return array();
81+
}
7982
return $this->__header;
8083
}
8184

@@ -96,6 +99,9 @@ function setBoundary() {
9699
* @return string
97100
*/
98101
function getBoundary() {
102+
if (empty($this->__boundary)) {
103+
return null;
104+
}
99105
return $this->__boundary;
100106
}
101107

@@ -106,6 +112,9 @@ function getBoundary() {
106112
* @return string
107113
*/
108114
function getMessage() {
115+
if (empty($this->__message)) {
116+
return array();
117+
}
109118
return $this->__message;
110119
}
111120

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

198-
$this->Controller =& new EmailTestController();
207+
$this->Controller = new EmailTestController();
199208

200-
restore_error_handler();
201-
@$this->Controller->Component->init($this->Controller);
202-
set_error_handler('simpleTestErrorHandler');
209+
$this->Controller->Component->init($this->Controller);
203210

204211
$this->Controller->EmailTest->initialize($this->Controller, array());
205212
ClassRegistry::addObject('view', new View($this->Controller));
@@ -219,7 +226,6 @@ function tearDown() {
219226
Configure::write('App.encoding', $this->_appEncoding);
220227
App::build();
221228
$this->Controller->Session->delete('Message');
222-
restore_error_handler();
223229
ClassRegistry::flush();
224230
}
225231

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

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

551557
$this->assertTrue($this->Controller->EmailTest->getConnectionSocket());
@@ -591,7 +597,7 @@ function testSendDebug() {
591597
* @return void
592598
*/
593599
function testSendDebugWithNoSessions() {
594-
$session =& $this->Controller->Session;
600+
$session = $this->Controller->Session;
595601
unset($this->Controller->Session);
596602
$this->Controller->EmailTest->to = 'postmaster@localhost';
597603
$this->Controller->EmailTest->from = 'noreply@example.com';

0 commit comments

Comments
 (0)