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