aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Settings/Controller/UsersControllerTest.php210
-rw-r--r--tests/Settings/Mailer/NewUserMailHelperTest.php639
-rw-r--r--tests/data/emails/new-account-email-custom.html187
-rw-r--r--tests/data/emails/new-account-email-custom.txt11
-rw-r--r--tests/data/emails/new-account-email.html9
-rw-r--r--tests/lib/Mail/EMailTemplateTest.php112
6 files changed, 955 insertions, 213 deletions
diff --git a/tests/Settings/Controller/UsersControllerTest.php b/tests/Settings/Controller/UsersControllerTest.php
index 52a9a1cc844..d7961e2332b 100644
--- a/tests/Settings/Controller/UsersControllerTest.php
+++ b/tests/Settings/Controller/UsersControllerTest.php
@@ -12,8 +12,9 @@ namespace Tests\Settings\Controller;
use OC\Accounts\AccountManager;
use OC\Group\Manager;
-use OC\Mail\EMailTemplate;
+use OC\Mail\IEMailTemplate;
use OC\Settings\Controller\UsersController;
+use OC\Settings\Mailer\NewUserMailHelper;
use OCP\App\IAppManager;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
@@ -69,6 +70,8 @@ class UsersControllerTest extends \Test\TestCase {
private $secureRandom;
/** @var ITimeFactory | \PHPUnit_Framework_MockObject_MockObject */
private $timeFactory;
+ /** @var NewUserMailHelper|\PHPUnit_Framework_MockObject_MockObject */
+ private $newUserMailHelper;
/** @var ICrypto | \PHPUnit_Framework_MockObject_MockObject */
private $crypto;
@@ -80,7 +83,6 @@ class UsersControllerTest extends \Test\TestCase {
$this->userSession = $this->createMock(IUserSession::class);
$this->config = $this->createMock(IConfig::class);
$this->logger = $this->createMock(ILogger::class);
- $this->defaults = $this->createMock(\OC_Defaults::class);
$this->mailer = $this->createMock(IMailer::class);
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->appManager = $this->createMock(IAppManager::class);
@@ -89,6 +91,7 @@ class UsersControllerTest extends \Test\TestCase {
$this->secureRandom = $this->createMock(ISecureRandom::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
$this->crypto = $this->createMock(ICrypto::class);
+ $this->newUserMailHelper = $this->createMock(NewUserMailHelper::class);
$this->l = $this->createMock(IL10N::class);
$this->l->method('t')
->will($this->returnCallback(function ($text, $parameters = []) {
@@ -127,16 +130,13 @@ class UsersControllerTest extends \Test\TestCase {
$isAdmin,
$this->l,
$this->logger,
- $this->defaults,
$this->mailer,
- 'no-reply@nextcloud.com',
$this->urlGenerator,
$this->appManager,
$this->avatarManager,
$this->accountManager,
$this->secureRandom,
- $this->timeFactory,
- $this->crypto
+ $this->newUserMailHelper
);
} else {
return $this->getMockBuilder(UsersController::class)
@@ -151,16 +151,13 @@ class UsersControllerTest extends \Test\TestCase {
$isAdmin,
$this->l,
$this->logger,
- $this->defaults,
$this->mailer,
- 'no-reply@nextcloud.com',
$this->urlGenerator,
$this->appManager,
$this->avatarManager,
$this->accountManager,
$this->secureRandom,
- $this->timeFactory,
- $this->crypto
+ $this->newUserMailHelper
]
)->setMethods($mockedMethods)->getMock();
}
@@ -1418,91 +1415,11 @@ class UsersControllerTest extends \Test\TestCase {
*/
public function testCreateSuccessfulWithValidEmailAdmin() {
$controller = $this->getController(true);
- $message = $this->getMockBuilder('\OC\Mail\Message')
- ->disableOriginalConstructor()->getMock();
- $message
- ->expects($this->at(0))
- ->method('setTo')
- ->with(['validMail@Adre.ss' => 'foo']);
- $message
- ->expects($this->at(1))
- ->method('setSubject')
- ->with('Your Nextcloud account was created');
-
- $this->urlGenerator
- ->expects($this->at(0))
- ->method('getAbsoluteURL')
- ->with('/')
- ->willReturn('https://example.org/');
- $this->urlGenerator
- ->expects($this->at(1))
- ->method('imagePath')
- ->with('', 'logo-mail-header.png')
- ->willReturn('/img/logo-mail-header.png');
- $this->urlGenerator
- ->expects($this->at(2))
- ->method('getAbsoluteURL')
- ->with('/img/logo-mail-header.png')
- ->willReturn('https://example.org/img/logo-mail-header.png');
- $this->urlGenerator
- ->expects($this->at(3))
- ->method('imagePath')
- ->with('', 'logo-mail-footer.png')
- ->willReturn('/img/logo-mail-footer.png');
- $this->urlGenerator
- ->expects($this->at(4))
- ->method('getAbsoluteURL')
- ->with('/img/logo-mail-footer.png')
- ->willReturn('https://example.org/img/logo-mail-footer.png');
- $this->defaults
- ->expects($this->any())
- ->method('getName')
- ->willReturn('Nextcloud');
- $this->defaults
- ->expects($this->any())
- ->method('getSlogan')
- ->willReturn('A safe home for your data');
-
- $emailTemplate = new EMailTemplate($this->defaults);
- $emailTemplate->addHeader('https://example.org/img/logo-mail-header.png');
- $emailTemplate->addHeading('Welcome aboard');
- $emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.');
- $emailTemplate->addBodyText('Your username is: foo');
- $emailTemplate->addBodyButtonGroup(
- 'Go to Nextcloud', 'https://example.org/',
- 'Install Client', 'https://nextcloud.com/install/#install-clients'
- );
- $emailTemplate->addFooter(
- 'https://example.org/img/logo-mail-footer.png',
- 'Nextcloud - A safe home for your data<br>This is an automatically generated email, please do not reply.'
- );
-
- $message
- ->expects($this->at(2))
- ->method('setHtmlBody')
- ->with($emailTemplate->renderHTML());
- $message
- ->expects($this->at(3))
- ->method('setPlainBody')
- ->with($emailTemplate->renderText());
- $message
- ->expects($this->at(4))
- ->method('setFrom')
- ->with(['no-reply@nextcloud.com' => 'Nextcloud']);
-
$this->mailer
->expects($this->at(0))
->method('validateMailAddress')
->with('validMail@Adre.ss')
->will($this->returnValue(true));
- $this->mailer
- ->expects($this->at(1))
- ->method('createMessage')
- ->will($this->returnValue($message));
- $this->mailer
- ->expects($this->at(2))
- ->method('send')
- ->with($message);
$user = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
@@ -1523,6 +1440,17 @@ class UsersControllerTest extends \Test\TestCase {
->method('getBackendClassName')
->will($this->returnValue('bar'));
+ $emailTemplate = $this->createMock(IEMailTemplate::class);
+ $this->newUserMailHelper
+ ->expects($this->at(0))
+ ->method('generateTemplate')
+ ->with($user, false)
+ ->willReturn($emailTemplate);
+ $this->newUserMailHelper
+ ->expects($this->at(1))
+ ->method('sendMail')
+ ->with($user, $emailTemplate);
+
$this->userManager
->expects($this->once())
->method('createUser')
@@ -2334,106 +2262,22 @@ class UsersControllerTest extends \Test\TestCase {
->method('getSubAdmin')
->will($this->returnValue($subadmin));
- $this->secureRandom
- ->expects($this->at(0))
- ->method('generate')
- ->with(32)
- ->will($this->returnValue('abc123'));
- $this->secureRandom
- ->expects($this->at(1))
- ->method('generate')
- ->with(21,
- ISecureRandom::CHAR_DIGITS .
- ISecureRandom::CHAR_LOWER .
- ISecureRandom::CHAR_UPPER)
- ->will($this->returnValue('mytoken'));
-
$controller = $this->getController(true);
- $message = $this->getMockBuilder('\OC\Mail\Message')
- ->disableOriginalConstructor()->getMock();
- $message
- ->expects($this->at(0))
- ->method('setTo')
- ->with(['abc@example.org' => 'foo']);
- $message
- ->expects($this->at(1))
- ->method('setSubject')
- ->with('Your Nextcloud account was created');
-
- $this->urlGenerator
- ->expects($this->at(0))
- ->method('linkToRouteAbsolute')
- ->with('core.lost.resetform', ['userId' => 'foo', 'token' => 'mytoken'])
- ->will($this->returnValue('https://example.org/resetPassword/123'));
- $this->urlGenerator
- ->expects($this->at(1))
- ->method('imagePath')
- ->with('', 'logo-mail-header.png')
- ->willReturn('/img/logo-mail-header.png');
- $this->urlGenerator
- ->expects($this->at(2))
- ->method('getAbsoluteURL')
- ->with('/img/logo-mail-header.png')
- ->willReturn('https://example.org/img/logo-mail-header.png');
- $this->urlGenerator
- ->expects($this->at(3))
- ->method('imagePath')
- ->with('', 'logo-mail-footer.png')
- ->willReturn('/img/logo-mail-footer.png');
- $this->urlGenerator
- ->expects($this->at(4))
- ->method('getAbsoluteURL')
- ->with('/img/logo-mail-footer.png')
- ->willReturn('https://example.org/img/logo-mail-footer.png');
- $this->defaults
- ->expects($this->any())
- ->method('getName')
- ->willReturn('Nextcloud');
- $this->defaults
- ->expects($this->any())
- ->method('getSlogan')
- ->willReturn('A safe home for your data');
-
- $emailTemplate = new EMailTemplate($this->defaults);
- $emailTemplate->addHeader('https://example.org/img/logo-mail-header.png');
- $emailTemplate->addHeading('Welcome aboard John Doe');
- $emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.');
- $emailTemplate->addBodyText('Your username is: foo');
- $emailTemplate->addBodyButtonGroup(
- 'Set your password', 'https://example.org/resetPassword/123',
- 'Install Client', 'https://nextcloud.com/install/#install-clients'
- );
- $emailTemplate->addFooter(
- 'https://example.org/img/logo-mail-footer.png',
- 'Nextcloud - A safe home for your data<br>This is an automatically generated email, please do not reply.'
- );
-
- $message
- ->expects($this->at(2))
- ->method('setHtmlBody')
- ->with($emailTemplate->renderHTML());
- $message
- ->expects($this->at(3))
- ->method('setPlainBody')
- ->with($emailTemplate->renderText());
- $message
- ->expects($this->at(4))
- ->method('setFrom')
- ->with(['no-reply@nextcloud.com' => 'Nextcloud']);
-
$this->mailer
->expects($this->at(0))
->method('validateMailAddress')
->with('abc@example.org')
->will($this->returnValue(true));
- $this->mailer
+ $emailTemplate = $this->createMock(IEMailTemplate::class);
+ $this->newUserMailHelper
+ ->expects($this->at(0))
+ ->method('generateTemplate')
+ ->with($user, true)
+ ->willReturn($emailTemplate);
+ $this->newUserMailHelper
->expects($this->at(1))
- ->method('createMessage')
- ->will($this->returnValue($message));
- $this->mailer
- ->expects($this->at(2))
- ->method('send')
- ->with($message);
+ ->method('sendMail')
+ ->with($user, $emailTemplate);
$expectedResponse = new DataResponse(
[
diff --git a/tests/Settings/Mailer/NewUserMailHelperTest.php b/tests/Settings/Mailer/NewUserMailHelperTest.php
new file mode 100644
index 00000000000..e77e8e197b8
--- /dev/null
+++ b/tests/Settings/Mailer/NewUserMailHelperTest.php
@@ -0,0 +1,639 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Tests\Settings\Mailer;
+
+use OC\Mail\EMailTemplate;
+use OC\Mail\IEMailTemplate;
+use OC\Mail\Message;
+use OC\Settings\Mailer\NewUserMailHelper;
+use OCA\Theming\ThemingDefaults;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\IURLGenerator;
+use OCP\IUser;
+use OCP\Mail\IMailer;
+use OCP\Security\ICrypto;
+use OCP\Security\ISecureRandom;
+use Test\TestCase;
+
+class NewUserMailHelperTest extends TestCase {
+ /** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */
+ private $themingDefaults;
+ /** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
+ private $urlGenerator;
+ /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
+ private $l10n;
+ /** @var IMailer|\PHPUnit_Framework_MockObject_MockObject */
+ private $mailer;
+ /** @var ISecureRandom|\PHPUnit_Framework_MockObject_MockObject */
+ private $secureRandom;
+ /** @var ITimeFactory|\PHPUnit_Framework_MockObject_MockObject */
+ private $timeFactory;
+ /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
+ private $config;
+ /** @var ICrypto|\PHPUnit_Framework_MockObject_MockObject */
+ private $crypto;
+ /** @var NewUserMailHelper */
+ private $newUserMailHelper;
+
+ public function setUp() {
+ parent::setUp();
+
+ $this->themingDefaults = $this->createMock(ThemingDefaults::class);
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
+ $this->l10n = $this->createMock(IL10N::class);
+ $this->mailer = $this->createMock(IMailer::class);
+ $this->secureRandom = $this->createMock(ISecureRandom::class);
+ $this->timeFactory = $this->createMock(ITimeFactory::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->crypto = $this->createMock(ICrypto::class);
+ $this->l10n->method('t')
+ ->will($this->returnCallback(function ($text, $parameters = []) {
+ return vsprintf($text, $parameters);
+ }));
+
+ $this->newUserMailHelper = new NewUserMailHelper(
+ $this->themingDefaults,
+ $this->urlGenerator,
+ $this->l10n,
+ $this->mailer,
+ $this->secureRandom,
+ $this->timeFactory,
+ $this->config,
+ $this->crypto,
+ 'no-reply@nextcloud.com'
+ );
+ }
+
+ public function testGenerateTemplateWithPasswordResetToken() {
+ $this->secureRandom
+ ->expects($this->once())
+ ->method('generate')
+ ->with(21,
+ ISecureRandom::CHAR_DIGITS .
+ ISecureRandom::CHAR_LOWER .
+ ISecureRandom::CHAR_UPPER
+ )
+ ->willReturn('MySuperLongSecureRandomToken');
+ $this->timeFactory
+ ->expects($this->once())
+ ->method('getTime')
+ ->willReturn('12345');
+ /** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
+ $user = $this->createMock(IUser::class);
+ $user
+ ->expects($this->at(0))
+ ->method('getEmailAddress')
+ ->willReturn('recipient@example.com');
+ $user
+ ->expects($this->at(1))
+ ->method('getEmailAddress')
+ ->willReturn('recipient@example.com');
+ $this->config
+ ->expects($this->at(0))
+ ->method('getSystemValue')
+ ->with('secret')
+ ->willReturn('MyInstanceWideSecret');
+ $this->crypto
+ ->expects($this->once())
+ ->method('encrypt')
+ ->with('12345:MySuperLongSecureRandomToken', 'recipient@example.comMyInstanceWideSecret')
+ ->willReturn('TokenCiphertext');
+ $user
+ ->expects($this->at(2))
+ ->method('getUID')
+ ->willReturn('john');
+ $this->config
+ ->expects($this->at(1))
+ ->method('setUserValue')
+ ->with('john', 'core', 'lostpassword', 'TokenCiphertext');
+ $user
+ ->expects($this->at(3))
+ ->method('getUID')
+ ->willReturn('john');
+ $this->urlGenerator
+ ->expects($this->at(0))
+ ->method('linkToRouteAbsolute')
+ ->with('core.lost.resetform', ['userId' => 'john', 'token' => 'MySuperLongSecureRandomToken'])
+ ->willReturn('https://example.com/resetPassword/MySuperLongSecureRandomToken');
+ $user
+ ->expects($this->at(4))
+ ->method('getDisplayName')
+ ->willReturn('john');
+ $user
+ ->expects($this->at(5))
+ ->method('getUID')
+ ->willReturn('john');
+ $this->themingDefaults
+ ->expects($this->at(0))
+ ->method('getName')
+ ->willReturn('TestCloud');
+
+ $expectedHtmlBody = <<<EOF
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" style="-webkit-font-smoothing:antialiased;background:#f3f3f3!important">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta name="viewport" content="width=device-width">
+ <title></title>
+ <style type="text/css">@media only screen{html{min-height:100%;background:#F5F5F5}}@media only screen and (max-width:610px){table.body img{width:auto;height:auto}table.body center{min-width:0!important}table.body .container{width:95%!important}table.body .columns{height:auto!important;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;padding-left:30px!important;padding-right:30px!important}th.small-12{display:inline-block!important;width:100%!important}table.menu{width:100%!important}table.menu td,table.menu th{width:auto!important;display:inline-block!important}table.menu.vertical td,table.menu.vertical th{display:block!important}table.menu[align=center]{width:auto!important}}</style>
+</head>
+<body style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;Margin:0;background:#f3f3f3!important;box-sizing:border-box;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;min-width:100%;padding:0;text-align:left;width:100%!important">
+ <span class="preheader" style="color:#F5F5F5;display:none!important;font-size:1px;line-height:1px;max-height:0;max-width:0;mso-hide:all!important;opacity:0;overflow:hidden;visibility:hidden">
+ </span>
+ <table class="body" style="-webkit-font-smoothing:antialiased;Margin:0;background:#f3f3f3!important;border-collapse:collapse;border-spacing:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;height:100%;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="center" align="center" valign="top" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <center data-parsed="" style="min-width:580px;width:100%"><table align="center" class="wrapper header float-center" style="Margin:0 auto;background:#8a8a8a;background-color:;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:20px;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table align="center" class="container" style="Margin:0 auto;background:0 0;border-collapse:collapse;border-spacing:0;margin:0 auto;padding:0;text-align:inherit;vertical-align:top;width:580px">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table class="row collapse" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <center data-parsed="" style="min-width:580px;width:100%">
+ <img class="logo float-center" src="?v=" alt="logo" align="center" style="-ms-interpolation-mode:bicubic;Margin:0 auto;clear:both;display:block;float:none;margin:0 auto;max-height:100%;max-width:100px;outline:0;text-align:center;text-decoration:none;width:auto">
+ </center>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+</table>
+<table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="80px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:80px;font-weight:400;hyphens:auto;line-height:80px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table><table align="center" class="container main-heading float-center" style="Margin:0 auto;background:0 0!important;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:580px">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <h1 class="text-center" style="Margin:0;Margin-bottom:10px;color:inherit;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:24px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:center;word-wrap:normal">Welcome aboard</h1>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="40px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:40px;font-weight:400;hyphens:auto;line-height:40px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table><table align="center" class="wrapper content float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table align="center" class="container has-shadow" style="Margin:0 auto;background:#fefefe;border-collapse:collapse;border-spacing:0;box-shadow:0 1px 2px 0 rgba(0,0,0,.2),0 1px 3px 0 rgba(0,0,0,.1);margin:0 auto;padding:0;text-align:inherit;vertical-align:top;width:580px">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="60px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:60px;font-weight:400;hyphens:auto;line-height:60px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+ </table><table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+ <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">You have now an account, you can add, protect, and share your data.</p>
+ </th>
+ <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>
+ </tr>
+ </table>
+ </th>
+ </tr>
+ </tbody>
+</table><table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+ <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">Your username is: john</p>
+ </th>
+ <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>
+ </tr>
+ </table>
+ </th>
+ </tr>
+ </tbody>
+</table><table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="50px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:50px;font-weight:400;hyphens:auto;line-height:50px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table>
+<table align="center" class="row btn-group" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+ <center data-parsed="" style="min-width:490px;width:100%">
+ <table class="button btn default primary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;max-height:40px;max-width:200px;padding:0;text-align:center;vertical-align:top;width:auto">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:;border:0 solid ;border-collapse:collapse!important;color:#fefefe;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <a href="https://example.com/resetPassword/MySuperLongSecureRandomToken" style="Margin:0;border:0 solid ;border-radius:2px;color:#fefefe;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;padding:10px 25px 10px 25px;text-align:left;text-decoration:none">Set your password</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <table class="button btn default secondary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;max-height:40px;max-width:200px;padding:0;text-align:center;vertical-align:top;width:auto">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:#777;border:0 solid #777;border-collapse:collapse!important;color:#fefefe;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <a href="https://nextcloud.com/install/#install-clients" style="Margin:0;background-color:#fff;border:0 solid #777;border-radius:2px;color:#6C6C6C!important;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;outline:1px solid #CBCBCB;padding:10px 25px 10px 25px;text-align:left;text-decoration:none">Install Client</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </center>
+ </th>
+ <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>
+ </tr>
+ </table>
+ </th>
+ </tr>
+ </tbody>
+</table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+</table><table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="60px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:60px;font-weight:400;hyphens:auto;line-height:60px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table>
+<table align="center" class="wrapper footer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <center data-parsed="" style="min-width:580px;width:100%">
+ <table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="15px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:15px;font-weight:400;hyphens:auto;line-height:15px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+ </table>
+ <p class="text-center float-center" align="center" style="Margin:0;Margin-bottom:10px;color:#C8C8C8;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:12px;font-weight:400;line-height:16px;margin:0;margin-bottom:10px;padding:0;text-align:center"> - <br>This is an automatically generated email, please do not reply.</p>
+ </center>
+ </td>
+ </tr>
+</table> </center>
+ </td>
+ </tr>
+ </table>
+ <!-- prevent Gmail on iOS font size manipulation -->
+ <div style="display:none;white-space:nowrap;font:15px courier;line-height:0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
+ </body>
+</html>
+EOF;
+ $expectedTextBody = <<<EOF
+Welcome aboard
+
+You have now an account, you can add, protect, and share your data.
+
+Your username is: john
+
+Set your password: https://example.com/resetPassword/MySuperLongSecureRandomToken
+Install Client: https://nextcloud.com/install/#install-clients
+
+--
+ -
+This is an automatically generated email, please do not reply.
+EOF;
+
+ $result = $this->newUserMailHelper->generateTemplate($user, true);
+ $this->assertEquals($expectedHtmlBody, $result->renderHTML());
+ $this->assertEquals($expectedTextBody, $result->renderText());
+ $this->assertSame('OC\Mail\EMailTemplate', get_class($result));
+ }
+
+ public function testGenerateTemplateWithoutPasswordResetToken() {
+ $this->urlGenerator
+ ->expects($this->at(0))
+ ->method('getAbsoluteURL')
+ ->with('/')
+ ->willReturn('https://example.com/');
+
+ /** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
+ $user = $this->createMock(IUser::class);
+ $user
+ ->expects($this->at(0))
+ ->method('getDisplayName')
+ ->willReturn('John Doe');
+ $user
+ ->expects($this->at(1))
+ ->method('getUID')
+ ->willReturn('john');
+ $this->themingDefaults
+ ->expects($this->any())
+ ->method('getName')
+ ->willReturn('TestCloud');
+
+ $expectedHtmlBody = <<<EOF
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" style="-webkit-font-smoothing:antialiased;background:#f3f3f3!important">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta name="viewport" content="width=device-width">
+ <title></title>
+ <style type="text/css">@media only screen{html{min-height:100%;background:#F5F5F5}}@media only screen and (max-width:610px){table.body img{width:auto;height:auto}table.body center{min-width:0!important}table.body .container{width:95%!important}table.body .columns{height:auto!important;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;padding-left:30px!important;padding-right:30px!important}th.small-12{display:inline-block!important;width:100%!important}table.menu{width:100%!important}table.menu td,table.menu th{width:auto!important;display:inline-block!important}table.menu.vertical td,table.menu.vertical th{display:block!important}table.menu[align=center]{width:auto!important}}</style>
+</head>
+<body style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;Margin:0;background:#f3f3f3!important;box-sizing:border-box;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;min-width:100%;padding:0;text-align:left;width:100%!important">
+ <span class="preheader" style="color:#F5F5F5;display:none!important;font-size:1px;line-height:1px;max-height:0;max-width:0;mso-hide:all!important;opacity:0;overflow:hidden;visibility:hidden">
+ </span>
+ <table class="body" style="-webkit-font-smoothing:antialiased;Margin:0;background:#f3f3f3!important;border-collapse:collapse;border-spacing:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;height:100%;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="center" align="center" valign="top" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <center data-parsed="" style="min-width:580px;width:100%"><table align="center" class="wrapper header float-center" style="Margin:0 auto;background:#8a8a8a;background-color:;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:20px;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table align="center" class="container" style="Margin:0 auto;background:0 0;border-collapse:collapse;border-spacing:0;margin:0 auto;padding:0;text-align:inherit;vertical-align:top;width:580px">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table class="row collapse" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <center data-parsed="" style="min-width:580px;width:100%">
+ <img class="logo float-center" src="?v=" alt="logo" align="center" style="-ms-interpolation-mode:bicubic;Margin:0 auto;clear:both;display:block;float:none;margin:0 auto;max-height:100%;max-width:100px;outline:0;text-align:center;text-decoration:none;width:auto">
+ </center>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+</table>
+<table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="80px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:80px;font-weight:400;hyphens:auto;line-height:80px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table><table align="center" class="container main-heading float-center" style="Margin:0 auto;background:0 0!important;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:580px">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <h1 class="text-center" style="Margin:0;Margin-bottom:10px;color:inherit;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:24px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:center;word-wrap:normal">Welcome aboard John Doe</h1>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="40px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:40px;font-weight:400;hyphens:auto;line-height:40px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table><table align="center" class="wrapper content float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table align="center" class="container has-shadow" style="Margin:0 auto;background:#fefefe;border-collapse:collapse;border-spacing:0;box-shadow:0 1px 2px 0 rgba(0,0,0,.2),0 1px 3px 0 rgba(0,0,0,.1);margin:0 auto;padding:0;text-align:inherit;vertical-align:top;width:580px">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="60px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:60px;font-weight:400;hyphens:auto;line-height:60px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+ </table><table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+ <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">You have now an TestCloud account, you can add, protect, and share your data.</p>
+ </th>
+ <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>
+ </tr>
+ </table>
+ </th>
+ </tr>
+ </tbody>
+</table><table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+ <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">Your username is: john</p>
+ </th>
+ <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>
+ </tr>
+ </table>
+ </th>
+ </tr>
+ </tbody>
+</table><table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="50px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:50px;font-weight:400;hyphens:auto;line-height:50px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table>
+<table align="center" class="row btn-group" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+ <center data-parsed="" style="min-width:490px;width:100%">
+ <table class="button btn default primary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;max-height:40px;max-width:200px;padding:0;text-align:center;vertical-align:top;width:auto">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:;border:0 solid ;border-collapse:collapse!important;color:#fefefe;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <a href="https://example.com/" style="Margin:0;border:0 solid ;border-radius:2px;color:#fefefe;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;padding:10px 25px 10px 25px;text-align:left;text-decoration:none">Go to TestCloud</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <table class="button btn default secondary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;max-height:40px;max-width:200px;padding:0;text-align:center;vertical-align:top;width:auto">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:#777;border:0 solid #777;border-collapse:collapse!important;color:#fefefe;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <a href="https://nextcloud.com/install/#install-clients" style="Margin:0;background-color:#fff;border:0 solid #777;border-radius:2px;color:#6C6C6C!important;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;outline:1px solid #CBCBCB;padding:10px 25px 10px 25px;text-align:left;text-decoration:none">Install Client</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </center>
+ </th>
+ <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>
+ </tr>
+ </table>
+ </th>
+ </tr>
+ </tbody>
+</table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+</table><table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="60px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:60px;font-weight:400;hyphens:auto;line-height:60px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table>
+<table align="center" class="wrapper footer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <center data-parsed="" style="min-width:580px;width:100%">
+ <table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="15px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:15px;font-weight:400;hyphens:auto;line-height:15px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+ </table>
+ <p class="text-center float-center" align="center" style="Margin:0;Margin-bottom:10px;color:#C8C8C8;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:12px;font-weight:400;line-height:16px;margin:0;margin-bottom:10px;padding:0;text-align:center">TestCloud - <br>This is an automatically generated email, please do not reply.</p>
+ </center>
+ </td>
+ </tr>
+</table> </center>
+ </td>
+ </tr>
+ </table>
+ <!-- prevent Gmail on iOS font size manipulation -->
+ <div style="display:none;white-space:nowrap;font:15px courier;line-height:0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
+ </body>
+</html>
+EOF;
+ $expectedTextBody = <<<EOF
+Welcome aboard John Doe
+
+You have now an TestCloud account, you can add, protect, and share your data.
+
+Your username is: john
+
+Go to TestCloud: https://example.com/
+Install Client: https://nextcloud.com/install/#install-clients
+
+--
+TestCloud -
+This is an automatically generated email, please do not reply.
+EOF;
+
+ $result = $this->newUserMailHelper->generateTemplate($user, false);
+ $this->assertEquals($expectedHtmlBody, $result->renderHTML());
+ $this->assertEquals($expectedTextBody, $result->renderText());
+ $this->assertSame('OC\Mail\EMailTemplate', get_class($result));
+ }
+
+ public function testSendMail() {
+ /** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
+ $user = $this->createMock(IUser::class);
+ $user
+ ->expects($this->at(0))
+ ->method('getEMailAddress')
+ ->willReturn('recipient@example.com');
+ $user
+ ->expects($this->at(1))
+ ->method('getDisplayName')
+ ->willReturn('John Doe');
+ /** @var IEMailTemplate|\PHPUnit_Framework_MockObject_MockObject $emailTemplate */
+ $emailTemplate = $this->createMock(IEMailTemplate::class);
+ $message = $this->createMock(Message::class);
+ $message
+ ->expects($this->at(0))
+ ->method('setTo')
+ ->with(['recipient@example.com' => 'John Doe']);
+ $this->themingDefaults
+ ->expects($this->exactly(2))
+ ->method('getName')
+ ->willReturn('TestCloud');
+ $message
+ ->expects($this->at(1))
+ ->method('setSubject')
+ ->with('Your TestCloud account was created');
+ $message
+ ->expects($this->at(2))
+ ->method('setHtmlBody')
+ ->with($emailTemplate->renderHTML());
+ $message
+ ->expects($this->at(3))
+ ->method('setPlainBody')
+ ->with($emailTemplate->renderText());
+ $message
+ ->expects($this->at(4))
+ ->method('setFrom')
+ ->with(['no-reply@nextcloud.com' => 'TestCloud']);
+ $this->mailer
+ ->expects($this->once())
+ ->method('createMessage')
+ ->willReturn($message);
+
+ $this->newUserMailHelper->sendMail($user, $emailTemplate);
+ }
+}
diff --git a/tests/data/emails/new-account-email-custom.html b/tests/data/emails/new-account-email-custom.html
new file mode 100644
index 00000000000..10d3330604d
--- /dev/null
+++ b/tests/data/emails/new-account-email-custom.html
@@ -0,0 +1,187 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en" style="-webkit-font-smoothing:antialiased;background:#f3f3f3!important">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <meta name="viewport" content="width=device-width">
+ <title></title>
+ <style type="text/css">@media only screen{html{min-height:100%;background:#F5F5F5}}@media only screen and (max-width:610px){table.body img{width:auto;height:auto}table.body center{min-width:0!important}table.body .container{width:95%!important}table.body .columns{height:auto!important;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;padding-left:30px!important;padding-right:30px!important}th.small-12{display:inline-block!important;width:100%!important}table.menu{width:100%!important}table.menu td,table.menu th{width:auto!important;display:inline-block!important}table.menu.vertical td,table.menu.vertical th{display:block!important}table.menu[align=center]{width:auto!important}}</style>
+</head>
+<body style="-moz-box-sizing:border-box;-ms-text-size-adjust:100%;-webkit-box-sizing:border-box;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%;Margin:0;background:#f3f3f3!important;box-sizing:border-box;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;min-width:100%;padding:0;text-align:left;width:100%!important">
+ <span class="preheader" style="color:#F5F5F5;display:none!important;font-size:1px;line-height:1px;max-height:0;max-width:0;mso-hide:all!important;opacity:0;overflow:hidden;visibility:hidden">
+ </span>
+ <table class="body" style="-webkit-font-smoothing:antialiased;Margin:0;background:#f3f3f3!important;border-collapse:collapse;border-spacing:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;height:100%;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="center" align="center" valign="top" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <center data-parsed="" style="min-width:580px;width:100%"><table align="center" class="wrapper header float-center" style="Margin:0 auto;background:#8a8a8a;background-color:#0082c9;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:20px;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table align="center" class="container" style="Margin:0 auto;background:0 0;border-collapse:collapse;border-spacing:0;margin:0 auto;padding:0;text-align:inherit;vertical-align:top;width:580px">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table class="row collapse" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <center data-parsed="" style="min-width:580px;width:100%">
+ <img class="logo float-center" src="https://example.org/img/logo-mail-header.png?v=48" alt="logo" align="center" style="-ms-interpolation-mode:bicubic;Margin:0 auto;clear:both;display:block;float:none;margin:0 auto;max-height:100%;max-width:100px;outline:0;text-align:center;text-decoration:none;width:auto">
+ </center>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+</table>
+<table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="80px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:80px;font-weight:400;hyphens:auto;line-height:80px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table><table align="center" class="container main-heading float-center" style="Margin:0 auto;background:0 0!important;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:580px">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <h1 class="text-center" style="Margin:0;Margin-bottom:10px;color:inherit;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:24px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:center;word-wrap:normal">Welcome aboard</h1>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="40px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:40px;font-weight:400;hyphens:auto;line-height:40px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table><table align="center" class="wrapper content float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table align="center" class="container has-shadow" style="Margin:0 auto;background:#fefefe;border-collapse:collapse;border-spacing:0;box-shadow:0 1px 2px 0 rgba(0,0,0,.2),0 1px 3px 0 rgba(0,0,0,.1);margin:0 auto;padding:0;text-align:inherit;vertical-align:top;width:580px">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="60px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:60px;font-weight:400;hyphens:auto;line-height:60px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+ </table><table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+ <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">You have now an Nextcloud account, you can add, protect, and share your data.</p>
+ </th>
+ <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>
+ </tr>
+ </table>
+ </th>
+ </tr>
+ </tbody>
+</table><table class="row description" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+ <p class="text-left" style="Margin:0;Margin-bottom:10px;color:#777;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;margin-bottom:10px;padding:0;text-align:left">Your username is: abc</p>
+ </th>
+ <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>
+ </tr>
+ </table>
+ </th>
+ </tr>
+ </tbody>
+</table><table class="spacer" style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="50px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:50px;font-weight:400;hyphens:auto;line-height:50px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table>
+<table align="center" class="row btn-group" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th class="small-12 large-12 columns first last" style="Margin:0 auto;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0 auto;padding:0;padding-bottom:30px;padding-left:30px;padding-right:30px;text-align:left;width:550px">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <th style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left">
+ <center data-parsed="" style="min-width:490px;width:100%">
+ <table class="button btn default primary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;margin-right:15px;max-height:40px;max-width:200px;padding:0;text-align:center;vertical-align:top;width:auto">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:#0082c9;border:0 solid #0082c9;border-collapse:collapse!important;color:#fefefe;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <a href="https://example.org/resetPassword/123" style="Margin:0;border:0 solid #0082c9;border-radius:2px;color:#fefefe;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;padding:10px 25px 10px 25px;text-align:left;text-decoration:none">Set your password</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ <table class="button btn default secondary float-center" style="Margin:0 0 30px 0;border-collapse:collapse;border-spacing:0;display:inline-block;float:none;margin:0 0 30px 0;max-height:40px;max-width:200px;padding:0;text-align:center;vertical-align:top;width:auto">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <table style="border-collapse:collapse;border-spacing:0;padding:0;text-align:left;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;background:#777;border:0 solid #777;border-collapse:collapse!important;color:#fefefe;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <a href="https://nextcloud.com/install/#install-clients" style="Margin:0;background-color:#fff;border:0 solid #777;border-radius:2px;color:#6C6C6C!important;display:inline-block;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:regular;line-height:1.3;margin:0;outline:1px solid #CBCBCB;padding:10px 25px 10px 25px;text-align:left;text-decoration:none">Install Client</a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </center>
+ </th>
+ <th class="expander" style="Margin:0;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;line-height:1.3;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>
+ </tr>
+ </table>
+ </th>
+ </tr>
+ </tbody>
+</table>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+</table><table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="60px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:60px;font-weight:400;hyphens:auto;line-height:60px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+</table>
+<table align="center" class="wrapper footer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
+ <center data-parsed="" style="min-width:580px;width:100%">
+ <table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
+ <tbody>
+ <tr style="padding:0;text-align:left;vertical-align:top">
+ <td height="15px" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:15px;font-weight:400;hyphens:auto;line-height:15px;margin:0;mso-line-height-rule:exactly;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">&#xA0;</td>
+ </tr>
+ </tbody>
+ </table>
+ <p class="text-center float-center" align="center" style="Margin:0;Margin-bottom:10px;color:#C8C8C8;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:12px;font-weight:400;line-height:16px;margin:0;margin-bottom:10px;padding:0;text-align:center">TestCloud - A safe home for your data<br></p>
+ </center>
+ </td>
+ </tr>
+</table> </center>
+ </td>
+ </tr>
+ </table>
+ <!-- prevent Gmail on iOS font size manipulation -->
+ <div style="display:none;white-space:nowrap;font:15px courier;line-height:0">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
+ </body>
+</html> \ No newline at end of file
diff --git a/tests/data/emails/new-account-email-custom.txt b/tests/data/emails/new-account-email-custom.txt
new file mode 100644
index 00000000000..962128980e0
--- /dev/null
+++ b/tests/data/emails/new-account-email-custom.txt
@@ -0,0 +1,11 @@
+Welcome aboard
+
+You have now an Nextcloud account, you can add, protect, and share your data.
+
+Your username is: abc
+
+Set your password: https://example.org/resetPassword/123
+Install Client: https://nextcloud.com/install/#install-clients
+
+--
+TestCloud - A safe home for your data
diff --git a/tests/data/emails/new-account-email.html b/tests/data/emails/new-account-email.html
index 9b9155fa1d9..a32ad61c49c 100644
--- a/tests/data/emails/new-account-email.html
+++ b/tests/data/emails/new-account-email.html
@@ -22,8 +22,8 @@
<table class="row collapse" style="border-collapse:collapse;border-spacing:0;display:table;padding:0;position:relative;text-align:left;vertical-align:top;width:100%">
<tbody>
<tr style="padding:0;text-align:left;vertical-align:top">
- <center data-parsed="" style="min-width:580px;width:100%"><!-- TODO -->
- <img class="logo float-center" src="https://example.org/img/logo-mail-header.png" alt="logo" align="center" style="-ms-interpolation-mode:bicubic;Margin:0 auto;clear:both;display:block;float:none;margin:0 auto;max-height:100%;max-width:100px;outline:0;text-align:center;text-decoration:none;width:auto">
+ <center data-parsed="" style="min-width:580px;width:100%">
+ <img class="logo float-center" src="https://example.org/img/logo-mail-header.png?v=48" alt="logo" align="center" style="-ms-interpolation-mode:bicubic;Margin:0 auto;clear:both;display:block;float:none;margin:0 auto;max-height:100%;max-width:100px;outline:0;text-align:center;text-decoration:none;width:auto">
</center>
</tr>
</tbody>
@@ -165,8 +165,7 @@
<table align="center" class="wrapper footer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
<tr style="padding:0;text-align:left;vertical-align:top">
<td class="wrapper-inner" style="-moz-hyphens:auto;-webkit-hyphens:auto;Margin:0;border-collapse:collapse!important;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:16px;font-weight:400;hyphens:auto;line-height:1.3;margin:0;padding:0;text-align:left;vertical-align:top;word-wrap:break-word">
- <center data-parsed="" style="min-width:580px;width:100%"><!-- TODO -->
- <img class="logo float-center" src="https://example.org/img/logo-mail-footer.png" alt="logo" align="center" style="-ms-interpolation-mode:bicubic;Margin:0 auto;clear:both;display:block;float:none;margin:0 auto;max-height:100%;max-width:75px;outline:0;text-align:center;text-decoration:none;width:auto">
+ <center data-parsed="" style="min-width:580px;width:100%">
<table class="spacer float-center" style="Margin:0 auto;border-collapse:collapse;border-spacing:0;float:none;margin:0 auto;padding:0;text-align:center;vertical-align:top;width:100%">
<tbody>
<tr style="padding:0;text-align:left;vertical-align:top">
@@ -174,7 +173,7 @@
</tr>
</tbody>
</table>
- <p class="text-center float-center" align="center" style="Margin:0;Margin-bottom:10px;color:#0a0a0a;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:12px;font-weight:400;line-height:16px;margin:0;margin-bottom:10px;padding:0;text-align:center">TestCloud - A safe home for your data<br>This is an automatically generated email, please do not reply.</p>
+ <p class="text-center float-center" align="center" style="Margin:0;Margin-bottom:10px;color:#C8C8C8;font-family:Lucida Grande,Geneva,Verdana,sans-serif;font-size:12px;font-weight:400;line-height:16px;margin:0;margin-bottom:10px;padding:0;text-align:center">TestCloud - A safe home for your data<br>This is an automatically generated email, please do not reply.</p>
</center>
</td>
</tr>
diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php
index 3acb742aeca..47fe09aabbb 100644
--- a/tests/lib/Mail/EMailTemplateTest.php
+++ b/tests/lib/Mail/EMailTemplateTest.php
@@ -24,51 +24,113 @@
namespace Test\Mail;
use OC\Mail\EMailTemplate;
-use OC_Defaults;
+use OCA\Theming\ThemingDefaults;
+use OCP\IL10N;
+use OCP\IURLGenerator;
use Test\TestCase;
class EMailTemplateTest extends TestCase {
- /** @var OC_Defaults */
+ /** @var ThemingDefaults|\PHPUnit_Framework_MockObject_MockObject */
private $defaults;
-
- function setUp() {
+ /** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
+ private $urlGenerator;
+ /** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
+ private $l10n;
+ /** @var EMailTemplate */
+ private $emailTemplate;
+
+ public function setUp() {
parent::setUp();
- $this->defaults = $this->getMockBuilder('\OC_Defaults')
- ->disableOriginalConstructor()->getMock();
+ $this->defaults = $this->createMock(ThemingDefaults::class);
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
+ $this->l10n = $this->createMock(IL10N::class);
+ $this->emailTemplate = new EMailTemplate(
+ $this->defaults,
+ $this->urlGenerator,
+ $this->l10n
+ );
+ }
+
+ public function testEMailTemplateCustomFooter() {
$this->defaults
->expects($this->any())
->method('getColorPrimary')
->willReturn('#0082c9');
- }
-
- public function testEMailTemplate() {
- $emailTemplate = new EMailTemplate($this->defaults);
-
- $emailTemplate->addHeader('https://example.org/img/logo-mail-header.png');
-
- $emailTemplate->addHeading('Welcome aboard');
- $emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.');
- $emailTemplate->addBodyText('Your username is: abc');
-
-
- $emailTemplate->addBodyButtonGroup(
+ $this->defaults
+ ->expects($this->any())
+ ->method('getLogo')
+ ->willReturn('/img/logo-mail-header.png');
+ $this->defaults
+ ->expects($this->any())
+ ->method('getCacheBusterCounter')
+ ->willReturn('48');
+ $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');
+ $this->emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.');
+ $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'
);
-
- $emailTemplate->addFooter(
- 'https://example.org/img/logo-mail-footer.png',
+ $this->emailTemplate->addFooter(
'TestCloud - A safe home for your data<br>This is an automatically generated email, please do not reply.'
);
$expectedHTML = file_get_contents(\OC::$SERVERROOT . '/tests/data/emails/new-account-email.html');
- $this->assertSame($expectedHTML, $emailTemplate->renderHTML());
+ $this->assertSame($expectedHTML, $this->emailTemplate->renderHTML());
+ $expectedTXT = file_get_contents(\OC::$SERVERROOT . '/tests/data/emails/new-account-email.txt');
+ $this->assertSame($expectedTXT, $this->emailTemplate->renderText());
+ }
+ public function testEMailTemplateDefaultFooter() {
+ $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->defaults
+ ->expects($this->any())
+ ->method('getCacheBusterCounter')
+ ->willReturn('48');
+ $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');
+ $this->emailTemplate->addBodyText('You have now an Nextcloud account, you can add, protect, and share your data.');
+ $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'
+ );
+ $this->emailTemplate->addFooter();
- $expectedTXT = file_get_contents(\OC::$SERVERROOT . '/tests/data/emails/new-account-email.txt');
- $this->assertSame($expectedTXT, $emailTemplate->renderText());
+ $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.txt');
+ $this->assertSame($expectedTXT, $this->emailTemplate->renderText());
}