Skipping EmailTest::testBadSmtpSend() and EmailTest::testSmtpSend() if suite can not connect to smtp

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5396 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-07-08 02:03:52 +00:00
parent 16332140bf
commit b2805cff95

View file

@ -49,21 +49,27 @@ class EmailTest extends CakeTestCase {
} }
function testBadSmtpSend() { function testBadSmtpSend() {
$this->Controller->Email->smtpOptions['host'] = 'blah'; if(@fsockopen('localhost', 25)) {
$this->assertFalse($this->Controller->Email->send('Should not work')); $this->skipUnless(@fsockopen('localhost', 25), 'Must be able to connect to localhost port');
$this->Controller->Email->smtpOptions['host'] = 'blah';
$this->assertFalse($this->Controller->Email->send('Should not work'));
} else {
$this->skipUnless(@fsockopen('localhost', 25), 'Must be able to connect to localhost port');
}
} }
function testSmtpSend() { function testSmtpSend() {
$this->assertTrue(@fsockopen('localhost', 25), "Local mail server is running"); if(@fsockopen('localhost', 25)) {
$this->Controller->Email->reset(); $this->assertTrue(@fsockopen('localhost', 25), "Local mail server is running");
$this->Controller->Email->to = 'chartjes@localhost'; $this->Controller->Email->reset();
$this->Controller->Email->subject = 'Cake SMTP test'; $this->Controller->Email->to = 'chartjes@localhost';
$this->Controller->Email->replyTo = 'noreply@example.com'; $this->Controller->Email->subject = 'Cake SMTP test';
$this->Controller->Email->from = 'noreply@example.com'; $this->Controller->Email->replyTo = 'noreply@example.com';
$this->Controller->Email->delivery = 'smtp'; $this->Controller->Email->from = 'noreply@example.com';
$this->Controller->Email->template = null; $this->Controller->Email->delivery = 'smtp';
$this->assertTrue($this->Controller->Email->send("This is the body of the message")); $this->Controller->Email->template = null;
$this->assertTrue($this->Controller->Email->send("This is the body of the message"));
}
} }
} }
?> ?>