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