mimemail.test 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * @file
  4. * Functionality tests for the Mime Mail module.
  5. *
  6. * @ingroup mimemail
  7. */
  8. require_once(dirname(__FILE__) . '/../mimemail.inc');
  9. /**
  10. * Tests helper functions from the Mime Mail module.
  11. */
  12. class MimeMailUnitTestCase extends DrupalUnitTestCase {
  13. public static function getInfo() {
  14. return array(
  15. 'name' => 'Mime Mail unit tests',
  16. 'description' => 'Test that Mime Mail helper functions work properly.',
  17. 'group' => 'Mime Mail',
  18. );
  19. }
  20. function setUp() {
  21. drupal_load('module', 'mimemail');
  22. parent::setUp();
  23. }
  24. function testHeaders() {
  25. // Test the regular expression for extracting the mail address.
  26. $chars = array('-', '.', '+', '_');
  27. $name = $this->randomString();
  28. $local = $this->randomName() . $chars[array_rand($chars)] . $this->randomName();
  29. $domain = $this->randomName() . '-' . $this->randomName() . '.' . $this->randomName(rand(2,4));
  30. $headers = mimemail_headers(array(), "$name <$local@$domain>");
  31. $result = $headers['Return-Path'];
  32. $expected = "<$local@$domain>";
  33. $this->assertIdentical($result, $expected, 'Return-Path header field correctly set.');
  34. }
  35. function testUrl() {
  36. $result = _mimemail_url('#');
  37. $this->assertIdentical($result, '#', 'Hash mark URL without fragment left intact.');
  38. }
  39. }