function DevelMailTest::testMail

Test mail logging functionality.

File

./devel.test, line 35

Class

DevelMailTest
Test devel mail functionality.

Code

function testMail() {
    require_once 'devel.mail.inc';
    $message = array();
    $message['to'] = 'drupal@example.com';
    $message['subject'] = 'Test mail';
    $message['headers'] = array(
        'From' => 'postmaster@example.com',
        'X-stupid' => 'dumb',
    );
    $message['body'] = "I am the body of this message";
    $d = new DevelMailLog();
    $filename = $d->getFileName($message);
    $content = $d->composeMessage($message);
    $expected_filename = $d->getOutputDirectory() . '/drupal@example.com-Test_mail-' . date('y-m-d_his') . '.mail.txt';
    $this->assertEqual($filename, $expected_filename);
    $this->assertEqual($content, 'From: postmaster@example.com
X-stupid: dumb
To: drupal@example.com
Subject: Test mail

I am the body of this message');
}