xref: /plugin/smtp/_test/message.test.php (revision 1992a185db4f78a85ada840e46f664af6c3febb5)
125673c62SAndreas Gohr<?php
2210e2f5dSAndreas Gohr
325673c62SAndreas Gohr/**
425673c62SAndreas Gohr * General tests for the smtp plugin
525673c62SAndreas Gohr *
625673c62SAndreas Gohr * @group plugin_smtp
725673c62SAndreas Gohr * @group plugins
825673c62SAndreas Gohr */
9210e2f5dSAndreas Gohrclass message_plugin_smtp_test extends DokuWikiTest
10210e2f5dSAndreas Gohr{
11*1992a185SAnna Dabrowska    public function setUp(): void
12210e2f5dSAndreas Gohr    {
1325673c62SAndreas Gohr        parent::setUp();
1425673c62SAndreas Gohr        require_once __DIR__ . '/../loader.php';
1525673c62SAndreas Gohr    }
1625673c62SAndreas Gohr
17210e2f5dSAndreas Gohr    public function test_body()
18210e2f5dSAndreas Gohr    {
19210e2f5dSAndreas Gohr        $input = join("\r\n", [
20210e2f5dSAndreas Gohr            'X-Mailer: DokuWiki',
21210e2f5dSAndreas Gohr            'X-Dokuwiki-User: admin',
22210e2f5dSAndreas Gohr            'X-Dokuwiki-Title: Test Wiki',
23210e2f5dSAndreas Gohr            'X-Dokuwiki-Server: localhost.localhost',
24210e2f5dSAndreas Gohr            'From: a@example.com',
25210e2f5dSAndreas Gohr            'To: b@example.com',
26210e2f5dSAndreas Gohr            'Bcc: c@example.com, d@example.com,',
27210e2f5dSAndreas Gohr            '     d@example.com',
28210e2f5dSAndreas Gohr            'Subject: A test',
29210e2f5dSAndreas Gohr            '',
30210e2f5dSAndreas Gohr            'This is the body of the mail',
31210e2f5dSAndreas Gohr            'Bcc: this is not a header line',
32210e2f5dSAndreas Gohr            'end of message',
33210e2f5dSAndreas Gohr        ]);
3425673c62SAndreas Gohr
35210e2f5dSAndreas Gohr        $expect = join("\r\n", [
36210e2f5dSAndreas Gohr            'X-Mailer: DokuWiki',
37210e2f5dSAndreas Gohr            'X-Dokuwiki-User: admin',
38210e2f5dSAndreas Gohr            'X-Dokuwiki-Title: Test Wiki',
39210e2f5dSAndreas Gohr            'X-Dokuwiki-Server: localhost.localhost',
40210e2f5dSAndreas Gohr            'From: a@example.com',
41210e2f5dSAndreas Gohr            'To: b@example.com',
42210e2f5dSAndreas Gohr            'Subject: A test',
43210e2f5dSAndreas Gohr            '',
44210e2f5dSAndreas Gohr            'This is the body of the mail',
45210e2f5dSAndreas Gohr            'Bcc: this is not a header line',
46210e2f5dSAndreas Gohr            'end of message',
47210e2f5dSAndreas Gohr        ]);
4825673c62SAndreas Gohr        $expect .= "\r\n\r\n.\r\n";
4925673c62SAndreas Gohr
5025673c62SAndreas Gohr        $message = new \splitbrain\dokuwiki\plugin\smtp\Message('', '', $input);
5125673c62SAndreas Gohr
5225673c62SAndreas Gohr        $this->assertEquals($expect, $message->toString());
5325673c62SAndreas Gohr
5425673c62SAndreas Gohr    }
5525673c62SAndreas Gohr}
56