I've decided to go with SimpleTest and after reading the docs partway through I got impatient and though bah I'll just start and see what happens (I was finding the docs a little tedious to be honest).
I figured the best place to start would be at the heart of Swift and test the connection object (SMTP first).
I've only written one test so far and hopefully, with just a few adjustments it should apply to PHP5 too (loose the interface).
The test looks a bit long and repetitive though. Am I testing too many factors that are just, well, obvious?
Code: Select all
<?php
set_time_limit(0);
require_once('../docs/Swift_IConnection.php');
require_once('../Swift/Swift_SMTP_Connection.php');
require_once('../../simpletest/unit_tester.php');
require_once('../../simpletest/reporter.php');
class TestOfSMTPConnection extends UnitTestCase
{
public function TestCreatingUnencryptedConnectionOnDefaultPort()
{
$connection = new Swift_SMTP_Connection('smtp.gmail.com', SWIFT_DEFAULT_PORT);
$this->assertFalse($connection->isConnected());
$this->assertFalse($connection->readHook);
$this->assertFalse($connection->writeHook);
$this->assertTrue($connection->start());
$this->assertTrue($connection->isConnected());
$this->assertTrue($connection->readHook);
$this->assertTrue($connection->writeHook);
unset($connection);
$connection = new Swift_SMTP_Connection('smtp.gmail.com');
$this->assertFalse($connection->isConnected());
$this->assertFalse($connection->readHook);
$this->assertFalse($connection->writeHook);
$this->assertTrue($connection->start());
$this->assertTrue($connection->isConnected());
$this->assertTrue($connection->readHook);
$this->assertTrue($connection->writeHook);
unset($connection);
}
}
$test =& new TestOfSMTPConnection;
$test->run(new HtmlReporter());
?>Maybe this is more sensible?
Code: Select all
<?php
set_time_limit(0);
require_once('../docs/Swift_IConnection.php');
require_once('../Swift/Swift_SMTP_Connection.php');
require_once('../../simpletest/unit_tester.php');
require_once('../../simpletest/reporter.php');
class TestOfSMTPConnection extends UnitTestCase
{
public function TestCreatingUnencryptedConnectionOnDefaultPort()
{
$connection = new Swift_SMTP_Connection('smtp.gmail.com', SWIFT_DEFAULT_PORT);
$this->assertFalse($connection->isConnected());
$this->assertTrue($connection->start());
$this->assertTrue($connection->isConnected());
$this->assertTrue($connection->readHook);
$this->assertTrue($connection->writeHook);
unset($connection);
}
}
$test =& new TestOfSMTPConnection;
$test->run(new HtmlReporter());
?>Just looking for a "carry on..."
Cheers,
d11