1<?php
2
3/**
4 * General tests for the smtp plugin
5 *
6 * @group plugin_smtp
7 * @group plugins
8 */
9class message_plugin_smtp_test extends DokuWikiTest
10{
11    public function setUp()
12    {
13        parent::setUp();
14        require_once __DIR__ . '/../loader.php';
15    }
16
17    public function test_body()
18    {
19        $input = join("\r\n", [
20            'X-Mailer: DokuWiki',
21            'X-Dokuwiki-User: admin',
22            'X-Dokuwiki-Title: Test Wiki',
23            'X-Dokuwiki-Server: localhost.localhost',
24            'From: a@example.com',
25            'To: b@example.com',
26            'Bcc: c@example.com, d@example.com,',
27            '     d@example.com',
28            'Subject: A test',
29            '',
30            'This is the body of the mail',
31            'Bcc: this is not a header line',
32            'end of message',
33        ]);
34
35        $expect = join("\r\n", [
36            'X-Mailer: DokuWiki',
37            'X-Dokuwiki-User: admin',
38            'X-Dokuwiki-Title: Test Wiki',
39            'X-Dokuwiki-Server: localhost.localhost',
40            'From: a@example.com',
41            'To: b@example.com',
42            'Subject: A test',
43            '',
44            'This is the body of the mail',
45            'Bcc: this is not a header line',
46            'end of message',
47        ]);
48        $expect .= "\r\n\r\n.\r\n";
49
50        $message = new \splitbrain\dokuwiki\plugin\smtp\Message('', '', $input);
51
52        $this->assertEquals($expect, $message->toString());
53
54    }
55}
56