You are here

function SpamSpanMailtoTestCase::testSpamSpanMailto in SpamSpan filter 6

Test for proper conversion of mailto: URLs

File

./spamspan.test, line 169
Tests for the SpamSpan module

Class

SpamSpanMailtoTestCase

Code

function testSpamSpanMailto() {

  // plain
  $this
    ->assertEqual(spamspan("<a href='mailto:email@example.com'></a>"), '<span class="spamspan"><span class="u">email</span> [at] <span class="d">example [dot] com</span></span>', "Test plain mailto:");

  // with anchor text
  $this
    ->assertEqual(spamspan("<a href='mailto:email@example.com'>some text</a>"), '<span class="spamspan"><span class="u">email</span> [at] <span class="d">example [dot] com</span><span class="t"> (some text)</span></span>', "Test mailto: with anchor tag");

  // with an extra attribute
  $this
    ->assertEqual(spamspan("<a attribute='something' href='mailto:email@example.com'></a>"), '<span class="spamspan"><span class="u">email</span> [at] <span class="d">example [dot] com</span></span>', "test mailto: with extra attribute");

  // with nested tags
  $this
    ->assertEqual(spamspan("<a href='mailto:email@example.com'>some <em>text</em></a>"), '<span class="spamspan"><span class="u">email</span> [at] <span class="d">example [dot] com</span><span class="t"> (some <em>text</em>)</span></span>', "Test mailto: with nested tags");

  // with an email address as the tag contents
  $this
    ->assertEqual(spamspan("<a href='mailto:email@example.com'>email@example.com</a>"), '<span class="spamspan"><span class="u">email</span> [at] <span class="d">example [dot] com</span></span>', "Test mailto: with email as tag contents");

  // with a URL parameter string
  $this
    ->assertEqual(spamspan("<a href='mailto:email@example.com?subject=subject'>some text</a>"), '<span class="spamspan"><span class="u">email</span> [at] <span class="d">example [dot] com</span><span class="h"> (subject: subject) </span><span class="t"> (some text)</span></span>', "Test mailto: with a URL parameter string");

  // with a URL parameter string - multiple headers
  $this
    ->assertEqual(spamspan('<a href="mailto:email@example.com?subject=test%20subject&body=some%20text">some text</a>'), '<span class="spamspan"><span class="u">email</span> [at] <span class="d">example [dot] com</span><span class="h"> (subject: test%20subject, body: some%20text) </span><span class="t"> (some text)</span></span>', "Test mailto: with a URL parameter string - multiple headers");
}