Permalink
Browse files

Fixing skipIf calls so email test runs in a reasonable time frame whe…

…n there is no local smtp server.
  • Loading branch information...
1 parent e9d1948 commit 85ccd1f0963486551b77c71f5406524127fc444e @markstory markstory committed Sep 12, 2010
Showing with 16 additions and 5 deletions.
  1. +16 −5 cake/tests/cases/libs/controller/components/email.test.php
@@ -260,6 +260,9 @@ function __osFix($string) {
* @return void
*/
function testSmtpConfig() {
+ if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
+ return;
+ }
$this->Controller->EmailTest->delivery = 'smtp';
$this->Controller->EmailTest->smtpOptions = array();
$this->Controller->EmailTest->send('anything');
@@ -284,6 +287,9 @@ function testSmtpConfig() {
* @return void
*/
function testBadSmtpSend() {
+ if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
+ return;
+ }
$this->Controller->EmailTest->smtpOptions['host'] = 'blah';
$this->Controller->EmailTest->delivery = 'smtp';
$this->assertFalse($this->Controller->EmailTest->send('Should not work'));
@@ -296,7 +302,7 @@ function testBadSmtpSend() {
* @return void
*/
function testSmtpSend() {
- if (!$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
+ if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
return;
}
@@ -345,7 +351,7 @@ function testSmtpSend() {
* @return void
*/
function testSmtpEhlo() {
- if (!$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
+ if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
return;
}
@@ -402,7 +408,7 @@ function testSmtpEhlo() {
* @return void
*/
function testSmtpSendMultipleTo() {
- if (!$this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
+ if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
return;
}
$this->Controller->EmailTest->reset();
@@ -451,7 +457,9 @@ function testSmtpSendMultipleTo() {
* @return void
*/
function testAuthenticatedSmtpSend() {
- $this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost');
+ if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
+ return;
+ }
$this->Controller->EmailTest->to = 'postmaster@localhost';
$this->Controller->EmailTest->from = 'noreply@example.com';
@@ -642,7 +650,9 @@ function testTemplates() {
* @return void
*/
function testSmtpSendSocket() {
- $this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost');
+ if ($this->skipIf(!@fsockopen('localhost', 25), '%s No SMTP server running on localhost')) {
+ return;
+ }
$this->Controller->EmailTest->smtpOptions['timeout'] = 10;
$socket =& new CakeSocket(array_merge(array('protocol'=>'smtp'), $this->Controller->EmailTest->smtpOptions));
@@ -1037,6 +1047,7 @@ function testReset() {
$this->Controller->EmailTest->additionalParams = 'X-additional-header';
$this->Controller->EmailTest->delivery = 'smtp';
$this->Controller->EmailTest->smtpOptions['host'] = 'blah';
+ $this->Controller->EmailTest->smtpOptions['timeout'] = 0.5;
$this->Controller->EmailTest->attachments = array('attachment1', 'attachment2');
$this->Controller->EmailTest->textMessage = 'This is the body of the message';
$this->Controller->EmailTest->htmlMessage = 'This is the body of the message';

0 comments on commit 85ccd1f

Please sign in to comment.