mirror of
https://github.com/splitbrain/dokuwiki-plugin-smtp.git
synced 2025-07-22 12:01:04 +00:00
fixed tests
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
|
||||
language: php
|
||||
php:
|
||||
- "7.4"
|
||||
- "7.3"
|
||||
- "7.2"
|
||||
- "7.1"
|
||||
|
@ -1,49 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* General tests for the smtp plugin
|
||||
*
|
||||
* @group plugin_smtp
|
||||
* @group plugins
|
||||
*/
|
||||
class message_plugin_smtp_test extends DokuWikiTest {
|
||||
public function setUp() {
|
||||
class message_plugin_smtp_test extends DokuWikiTest
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
require_once __DIR__ . '/../loader.php';
|
||||
}
|
||||
|
||||
public function test_body() {
|
||||
$input = trim('
|
||||
X-Mailer: DokuWiki
|
||||
X-Dokuwiki-User: admin
|
||||
X-Dokuwiki-Title: Test Wiki
|
||||
X-Dokuwiki-Server: localhost.localhost
|
||||
From: a@example.com
|
||||
To: b@example.com
|
||||
Bcc: c@example.com, d@example.com,
|
||||
d@example.com
|
||||
Subject: A test
|
||||
public function test_body()
|
||||
{
|
||||
$input = join("\r\n", [
|
||||
'X-Mailer: DokuWiki',
|
||||
'X-Dokuwiki-User: admin',
|
||||
'X-Dokuwiki-Title: Test Wiki',
|
||||
'X-Dokuwiki-Server: localhost.localhost',
|
||||
'From: a@example.com',
|
||||
'To: b@example.com',
|
||||
'Bcc: c@example.com, d@example.com,',
|
||||
' d@example.com',
|
||||
'Subject: A test',
|
||||
'',
|
||||
'This is the body of the mail',
|
||||
'Bcc: this is not a header line',
|
||||
'end of message',
|
||||
]);
|
||||
|
||||
This is the body of the mail
|
||||
Bcc: this is not a header line
|
||||
end of message
|
||||
');
|
||||
|
||||
$expect = trim('
|
||||
X-Mailer: DokuWiki
|
||||
X-Dokuwiki-User: admin
|
||||
X-Dokuwiki-Title: Test Wiki
|
||||
X-Dokuwiki-Server: localhost.localhost
|
||||
From: a@example.com
|
||||
To: b@example.com
|
||||
Subject: A test
|
||||
|
||||
This is the body of the mail
|
||||
Bcc: this is not a header line
|
||||
end of message
|
||||
');
|
||||
$expect = join("\r\n", [
|
||||
'X-Mailer: DokuWiki',
|
||||
'X-Dokuwiki-User: admin',
|
||||
'X-Dokuwiki-Title: Test Wiki',
|
||||
'X-Dokuwiki-Server: localhost.localhost',
|
||||
'From: a@example.com',
|
||||
'To: b@example.com',
|
||||
'Subject: A test',
|
||||
'',
|
||||
'This is the body of the mail',
|
||||
'Bcc: this is not a header line',
|
||||
'end of message',
|
||||
]);
|
||||
$expect .= "\r\n\r\n.\r\n";
|
||||
|
||||
$message = new \splitbrain\dokuwiki\plugin\smtp\Message('','',$input);
|
||||
$message = new \splitbrain\dokuwiki\plugin\smtp\Message('', '', $input);
|
||||
|
||||
$this->assertEquals($expect, $message->toString());
|
||||
|
||||
|
@ -73,7 +73,7 @@ class Message extends \Tx\Mailer\Message {
|
||||
*/
|
||||
public function toString() {
|
||||
// we need to remove the BCC header here
|
||||
$lines = explode("\n", $this->body);
|
||||
$lines = preg_split('/\r?\n/', $this->body);
|
||||
$count = count($lines);
|
||||
for($i=0; $i<$count; $i++) {
|
||||
if(trim($lines[$i]) === '') break; // end of headers, we're done
|
||||
|
Reference in New Issue
Block a user