Archive for February, 2009

How do I unit test this?

Friday, February 20th, 2009

Came across a tricky bug a few weeks ago whilst working on some extremely fragile code.
This was the code:

settings.php

$mail_settings = array(
’server’ => ‘mail.example.com’,
‘port’ => 25
);

index.php

function send_email($recipient, $message)
{
include_once(’settings.php’);
$foo = new MailSender($mail_settings);
$foo->send($message, $recipient); //this was line number [...]