Nope, things like this in the testcases.... Mocks dude, Mocks
Code: Select all
protected function getWorkingMockConnection($send=1, $conn=null, $reconnect_at=0, $max_reconnect=0)
{
$count = 0;
if (!$conn) $conn = new FullMockConnection();
$conn->setReturnValueAt($count++, "read", "220 xxx ESMTP");
$conn->setReturnValueAt($count++, "read", "250-Hello xxx\r\n250 HELP");
$cycle = 0;
$reconnected = 0;
for ($i = 0; $i < $send; $i++)
{
$cycle++;
$conn->setReturnValueAt($count++, "read", "250 Ok");
$conn->setReturnValueAt($count++, "read", "250 Ok");
$conn->setReturnValueAt($count++, "read", "354 Go ahead");
$conn->setReturnValueAt($count++, "read", "250 Ok");
if ($reconnect_at && $reconnect_at == $cycle)
{
if (!$max_reconnect || $max_reconnect > $reconnected)
{
$conn->setReturnValueAt($count++, "read", "221 Bye");
$conn->setReturnValueAt($count++, "read", "220 xxx ESMTP");
$conn->setReturnValueAt($count++, "read", "250-Hello xxx\r\n250 HELP");
$cycle = 0;
$reconnected++;
}
}
}
$conn->setReturnValue("read", "250 Ok");
return $conn;
}
I need to refactor my tests actually because I started to copy that method into other testcases which I needn't have done.
The Units can't test everything, for example, they can't test if the email looks right. The smoke tests are the icing on the cake and act as end-to-end tests. At this point I always run the units and if they all pass I can assume the next step will but I go on to run all 5 smoke tests. I'm lucky in the respect of Swift's user-base size because if I release something with a problem in it, it will get picked up pretty fast. People seem pretty good at taking the initiative to email if something doesn't work properly.
EDIT | If you mean you want to quite literally test sending to 1000 addresses, just loop 1000 times with the same address. You can use that method above as a mock connection though (just mock Swift_Connection to create FullMockConnection).
Code: Select all
$mock_conn = $this->getWorkingMockConnection(1000);
That's ready to send 1000 emails, but not actually send them.