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