From be9a514dffa281af00bbfa54028cd84283f76ef5 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Tue, 11 Apr 2017 17:45:05 -0500 Subject: Allow to set text versions for the plain text email * allows different texts for HTML and text version of the email Signed-off-by: Morris Jobke --- tests/lib/Mail/EMailTemplateTest.php | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'tests/lib/Mail/EMailTemplateTest.php') diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php index ab90dc4aa07..9f80dad642a 100644 --- a/tests/lib/Mail/EMailTemplateTest.php +++ b/tests/lib/Mail/EMailTemplateTest.php @@ -126,4 +126,46 @@ class EMailTemplateTest extends TestCase { } + + public function testEMailTemplateAlternativePlainTexts() { + $this->defaults + ->expects($this->any()) + ->method('getColorPrimary') + ->willReturn('#0082c9'); + $this->defaults + ->expects($this->any()) + ->method('getName') + ->willReturn('TestCloud'); + $this->defaults + ->expects($this->any()) + ->method('getSlogan') + ->willReturn('A safe home for your data'); + $this->defaults + ->expects($this->any()) + ->method('getLogo') + ->willReturn('/img/logo-mail-header.png'); + $this->urlGenerator + ->expects($this->once()) + ->method('getAbsoluteURL') + ->with('/img/logo-mail-header.png') + ->willReturn('https://example.org/img/logo-mail-header.png'); + + $this->emailTemplate->addHeader(); + $this->emailTemplate->addHeading('Welcome aboard', 'Welcome aboard - text'); + $this->emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.', 'You have now an Nextcloud account, you can add, protect, and share your data. - text'); + $this->emailTemplate->addBodyText('Your username is: abc'); + $this->emailTemplate->addBodyButtonGroup( + 'Set your password', 'https://example.org/resetPassword/123', + 'Install Client', 'https://nextcloud.com/install/#install-clients', + 'Set your password - text', 'Install Client - text' + ); + $this->emailTemplate->addFooter(); + + $expectedHTML = file_get_contents(\OC::$SERVERROOT . '/tests/data/emails/new-account-email-custom.html'); + $this->assertSame($expectedHTML, $this->emailTemplate->renderHTML()); + $expectedTXT = file_get_contents(\OC::$SERVERROOT . '/tests/data/emails/new-account-email-custom-text-alternative.txt'); + $this->assertSame($expectedTXT, $this->emailTemplate->renderText()); + } + + } -- cgit v1.2.3