assertEqual($prefix.$shouldbe.$suffix, spamspan($prefix.$original.$suffix, "") ); } function testNoEmail() { // test that strings without emails a passed unchanged $noemails = array( 'no email here', 'oneword', '', 'notan@email', 'notan@email either', 'some text and notan.email@something here', ); while ($text = each($noemails)) { $this->assertEqual(spamspan($text, ""), $text); } } function testEmail() { // check that emails in odd places are properly converted // a list of address, together with what they should look like $emails = array('user@example.com' => 'user [at] example [dot] com', 'user@example.co.uk' => 'user [at] example [dot] co [dot] uk', 'user@example.museum' => 'user [at] example [dot] museum', 'user.user@example.com' => 'user.user [at] example [dot] com', 'user\'user@example.com' => 'user\'user [at] example [dot] com', 'user-user@example.com' => 'user-user [at] example [dot] com', 'user_user@example.com' => 'user_user [at] example [dot] com', 'user+user@example.com' => 'user+user [at] example [dot] com', ); print "Test for bare email\n"; foreach ($emails as $original => $shouldbe) { $this->checkEmail("","",$original,$shouldbe); } print "Test for email with text at the start\n"; foreach ($emails as $original => $shouldbe) { $this->checkEmail("some text here ","",$original,$shouldbe); } print "Test for email with text at the end\n"; foreach ($emails as $original => $shouldbe) { $this->checkEmail(""," some text here",$original,$shouldbe); } print "Test for email with text at the start and end\n"; foreach ($emails as $original => $shouldbe) { $this->checkEmail("some text here "," some text here",$original,$shouldbe); } print "Test for email with tags at the start and end\n"; foreach ($emails as $original => $shouldbe) { $this->checkEmail("
","
",$original,$shouldbe); } print "Test for email with trailing commas\n"; foreach ($emails as $original => $shouldbe) { $this->checkEmail("some text here. ",", Next sentence",$original,$shouldbe); } print "Test for email with trailing full stop\n"; foreach ($emails as $original => $shouldbe) { $this->checkEmail("some text here. ",". Next sentence",$original,$shouldbe); } print "Test for email with preceding tag\n"; foreach ($emails as $original => $shouldbe) { $this->checkEmail("","
",$original,$shouldbe); } print "Test for email with preceding tag, and no closing tag\n"; foreach ($emails as $original => $shouldbe) { $this->checkEmail("