summaryrefslogtreecommitdiffstats
path: root/tests/lib/Mail
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-04-16 15:55:39 +0200
committerMorris Jobke <hey@morrisjobke.de>2018-04-16 19:00:05 +0200
commit9ee1febf629fa4180c483fb4a2c82559f5c50392 (patch)
treefc9723ef0eba3b5dad8830cd725169231a35292d /tests/lib/Mail
parent056660bf7ce0e587be7276e640e424280ff66804 (diff)
downloadnextcloud-server-9ee1febf629fa4180c483fb4a2c82559f5c50392.tar.gz
nextcloud-server-9ee1febf629fa4180c483fb4a2c82559f5c50392.zip
Provide an option to disable HTML emails
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'tests/lib/Mail')
-rw-r--r--tests/lib/Mail/MailerTest.php5
-rw-r--r--tests/lib/Mail/MessageTest.php49
2 files changed, 53 insertions, 1 deletions
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index b0955a5d2fe..2dd4bca5190 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -95,6 +95,11 @@ class MailerTest extends TestCase {
}
public function testCreateMessage() {
+ $this->config
+ ->expects($this->any())
+ ->method('getSystemValue')
+ ->with('mail_send_plaintext_only', false)
+ ->will($this->returnValue(false));
$this->assertInstanceOf('\OC\Mail\Message', $this->mailer->createMessage());
}
diff --git a/tests/lib/Mail/MessageTest.php b/tests/lib/Mail/MessageTest.php
index 78fd5f1bb8b..4b656938e48 100644
--- a/tests/lib/Mail/MessageTest.php
+++ b/tests/lib/Mail/MessageTest.php
@@ -9,6 +9,7 @@
namespace Test\Mail;
use OC\Mail\Message;
+use OCP\Mail\IEMailTemplate;
use Swift_Message;
use Test\TestCase;
@@ -36,7 +37,7 @@ class MessageTest extends TestCase {
$this->swiftMessage = $this->getMockBuilder('\Swift_Message')
->disableOriginalConstructor()->getMock();
- $this->message = new Message($this->swiftMessage);
+ $this->message = new Message($this->swiftMessage, false);
}
/**
@@ -180,4 +181,50 @@ class MessageTest extends TestCase {
$this->message->setHtmlBody('<blink>Fancy Body</blink>');
}
+ public function testPlainTextRenderOption() {
+ /** @var \PHPUnit_Framework_MockObject_MockObject|Swift_Message $swiftMessage */
+ $swiftMessage = $this->getMockBuilder('\Swift_Message')
+ ->disableOriginalConstructor()->getMock();
+ /** @var \PHPUnit_Framework_MockObject_MockObject|IEMailTemplate $template */
+ $template = $this->getMockBuilder('\OCP\Mail\IEMailTemplate')
+ ->disableOriginalConstructor()->getMock();
+
+ $message = new Message($swiftMessage, true);
+
+ $template
+ ->expects($this->never())
+ ->method('renderHTML');
+ $template
+ ->expects($this->once())
+ ->method('renderText');
+ $template
+ ->expects($this->once())
+ ->method('renderSubject');
+
+ $message->useTemplate($template);
+ }
+
+ public function testBothRenderingOptions() {
+ /** @var \PHPUnit_Framework_MockObject_MockObject|Swift_Message $swiftMessage */
+ $swiftMessage = $this->getMockBuilder('\Swift_Message')
+ ->disableOriginalConstructor()->getMock();
+ /** @var \PHPUnit_Framework_MockObject_MockObject|IEMailTemplate $template */
+ $template = $this->getMockBuilder('\OCP\Mail\IEMailTemplate')
+ ->disableOriginalConstructor()->getMock();
+
+ $message = new Message($swiftMessage, false);
+
+ $template
+ ->expects($this->once())
+ ->method('renderHTML');
+ $template
+ ->expects($this->once())
+ ->method('renderText');
+ $template
+ ->expects($this->once())
+ ->method('renderSubject');
+
+ $message->useTemplate($template);
+ }
+
}