summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Controller/LostControllerTest.php58
-rw-r--r--tests/data/emails/new-account-email-single-button.txt2
-rw-r--r--tests/lib/Mail/EMailTemplateTest.php3
3 files changed, 55 insertions, 8 deletions
diff --git a/tests/Core/Controller/LostControllerTest.php b/tests/Core/Controller/LostControllerTest.php
index c8b8f87e73b..539fe016c8b 100644
--- a/tests/Core/Controller/LostControllerTest.php
+++ b/tests/Core/Controller/LostControllerTest.php
@@ -33,6 +33,7 @@ use OCP\IRequest;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserManager;
+use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
@@ -314,17 +315,32 @@ class LostControllerTest extends \Test\TestCase {
$message
->expects($this->at(2))
->method('setPlainBody')
- ->with('Use the following link to reset your password: https://example.tld/index.php/lostpassword/');
+ ->with('text body');
$message
->expects($this->at(3))
+ ->method('setHtmlBody')
+ ->with('HTML body');
+ $message
+ ->expects($this->at(4))
->method('setFrom')
->with(['lostpassword-noreply@localhost' => null]);
+ $emailTemplate = $this->createMock(IEMailTemplate::class);
+ $emailTemplate->expects($this->any())
+ ->method('renderHTML')
+ ->willReturn('HTML body');
+ $emailTemplate->expects($this->any())
+ ->method('renderText')
+ ->willReturn('text body');
$this->mailer
->expects($this->at(0))
+ ->method('createEMailTemplate')
+ ->willReturn($emailTemplate);
+ $this->mailer
+ ->expects($this->at(1))
->method('createMessage')
->will($this->returnValue($message));
$this->mailer
- ->expects($this->at(1))
+ ->expects($this->at(2))
->method('send')
->with($message);
@@ -385,17 +401,32 @@ class LostControllerTest extends \Test\TestCase {
$message
->expects($this->at(2))
->method('setPlainBody')
- ->with('Use the following link to reset your password: https://example.tld/index.php/lostpassword/');
+ ->with('text body');
$message
->expects($this->at(3))
+ ->method('setHtmlBody')
+ ->with('HTML body');
+ $message
+ ->expects($this->at(4))
->method('setFrom')
->with(['lostpassword-noreply@localhost' => null]);
+ $emailTemplate = $this->createMock(IEMailTemplate::class);
+ $emailTemplate->expects($this->any())
+ ->method('renderHTML')
+ ->willReturn('HTML body');
+ $emailTemplate->expects($this->any())
+ ->method('renderText')
+ ->willReturn('text body');
$this->mailer
->expects($this->at(0))
+ ->method('createEMailTemplate')
+ ->willReturn($emailTemplate);
+ $this->mailer
+ ->expects($this->at(1))
->method('createMessage')
->will($this->returnValue($message));
$this->mailer
- ->expects($this->at(1))
+ ->expects($this->at(2))
->method('send')
->with($message);
@@ -450,17 +481,32 @@ class LostControllerTest extends \Test\TestCase {
$message
->expects($this->at(2))
->method('setPlainBody')
- ->with('Use the following link to reset your password: https://example.tld/index.php/lostpassword/');
+ ->with('text body');
$message
->expects($this->at(3))
+ ->method('setHtmlBody')
+ ->with('HTML body');
+ $message
+ ->expects($this->at(4))
->method('setFrom')
->with(['lostpassword-noreply@localhost' => null]);
+ $emailTemplate = $this->createMock(IEMailTemplate::class);
+ $emailTemplate->expects($this->any())
+ ->method('renderHTML')
+ ->willReturn('HTML body');
+ $emailTemplate->expects($this->any())
+ ->method('renderText')
+ ->willReturn('text body');
$this->mailer
->expects($this->at(0))
+ ->method('createEMailTemplate')
+ ->willReturn($emailTemplate);
+ $this->mailer
+ ->expects($this->at(1))
->method('createMessage')
->will($this->returnValue($message));
$this->mailer
- ->expects($this->at(1))
+ ->expects($this->at(2))
->method('send')
->with($message)
->will($this->throwException(new \Exception()));
diff --git a/tests/data/emails/new-account-email-single-button.txt b/tests/data/emails/new-account-email-single-button.txt
index 55954961400..90ae35b0695 100644
--- a/tests/data/emails/new-account-email-single-button.txt
+++ b/tests/data/emails/new-account-email-single-button.txt
@@ -4,7 +4,7 @@ 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
+https://example.org/resetPassword/123
--
TestCloud - A safe home for your data
diff --git a/tests/lib/Mail/EMailTemplateTest.php b/tests/lib/Mail/EMailTemplateTest.php
index f9e1ecf29ca..2ba68dbbabb 100644
--- a/tests/lib/Mail/EMailTemplateTest.php
+++ b/tests/lib/Mail/EMailTemplateTest.php
@@ -157,7 +157,8 @@ class EMailTemplateTest extends TestCase {
$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->addBodyButton(
- 'Set your password', 'https://example.org/resetPassword/123'
+ 'Set your password', 'https://example.org/resetPassword/123',
+ false
);
$this->emailTemplate->addFooter();