You are here

public function MimeMailUnitTestCase::testHeaders in Mime Mail 7

File

tests/mimemail.test, line 30

Class

MimeMailUnitTestCase
Tests helper functions from the Mime Mail module.

Code

public function testHeaders() {

  // Test the regular expression for extracting the mail address.
  $chars = array(
    '-',
    '.',
    '+',
    '_',
  );
  $name = $this
    ->randomString();
  $local = $this
    ->randomName() . $chars[array_rand($chars)] . $this
    ->randomName();
  $domain = $this
    ->randomName() . '-' . $this
    ->randomName() . '.' . $this
    ->randomName(rand(2, 4));
  $headers = mimemail_headers(array(), "{$name} <{$local}@{$domain}>");
  $result = $headers['Return-Path'];
  $expected = "<{$local}@{$domain}>";
  $this
    ->assertIdentical($result, $expected, 'Return-Path header field correctly set.');
}