]> source.dussan.org Git - nextcloud-server.git/commitdiff
Extend mail shares unit tests to check the password and mail template
authorDaniel Calviño Sánchez <danxuliu@gmail.com>
Thu, 28 May 2020 18:26:00 +0000 (20:26 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Fri, 29 May 2020 19:38:28 +0000 (19:38 +0000)
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
apps/sharebymail/tests/ShareByMailProviderTest.php

index 07bba57a19cf03c4fedb3a2e294b86712e06f579..dde24138a485d0f29877d0dc46c2447ed2b95831 100644 (file)
@@ -263,11 +263,18 @@ class ShareByMailProviderTest extends TestCase {
                // The autogenerated password should be mailed to the receiver of the share.
                $this->settingsManager->expects($this->any())->method('enforcePasswordProtection')->willReturn(true);
                $this->settingsManager->expects($this->any())->method('sendPasswordByMail')->willReturn(true);
-               $instance->expects($this->once())->method('autoGeneratePassword')->with($share)->willReturn('password');
+               $instance->expects($this->once())->method('autoGeneratePassword')->with($share)->willReturn('autogeneratedPassword');
 
                $message = $this->createMock(IMessage::class);
                $message->expects($this->once())->method('setTo')->with(['receiver@example.com']);
                $this->mailer->expects($this->once())->method('createMessage')->willReturn($message);
+               $this->mailer->expects($this->once())->method('createEMailTemplate')->with('sharebymail.RecipientPasswordNotification', [
+                       'filename' => 'filename',
+                       'password' => 'autogeneratedPassword',
+                       'initiator' => 'owner',
+                       'initiatorEmail' => null,
+                       'shareWith' => 'receiver@example.com',
+               ]);
                $this->mailer->expects($this->once())->method('send');
 
                $this->assertSame('shareObject',
@@ -296,11 +303,18 @@ class ShareByMailProviderTest extends TestCase {
                // The autogenerated password should be mailed to the owner of the share.
                $this->settingsManager->expects($this->any())->method('enforcePasswordProtection')->willReturn(true);
                $this->settingsManager->expects($this->any())->method('sendPasswordByMail')->willReturn(true);
-               $instance->expects($this->once())->method('autoGeneratePassword')->with($share)->willReturn('password');
+               $instance->expects($this->once())->method('autoGeneratePassword')->with($share)->willReturn('autogeneratedPassword');
 
                $message = $this->createMock(IMessage::class);
                $message->expects($this->once())->method('setTo')->with(['owner@example.com' => 'Owner display name']);
                $this->mailer->expects($this->once())->method('createMessage')->willReturn($message);
+               $this->mailer->expects($this->once())->method('createEMailTemplate')->with('sharebymail.OwnerPasswordNotification', [
+                       'filename' => 'filename',
+                       'password' => 'autogeneratedPassword',
+                       'initiator' => 'Owner display name',
+                       'initiatorEmail' => 'owner@example.com',
+                       'shareWith' => 'receiver@example.com',
+               ]);
                $this->mailer->expects($this->once())->method('send');
 
                $user = $this->createMock(IUser::class);
@@ -533,6 +547,13 @@ class ShareByMailProviderTest extends TestCase {
                $share->expects($this->any())->method('getSendPasswordByTalk')->willReturn($newSendPasswordByTalk);
 
                if ($sendMail) {
+                       $this->mailer->expects($this->once())->method('createEMailTemplate')->with('sharebymail.RecipientPasswordNotification', [
+                               'filename' => 'filename',
+                               'password' => $plainTextPassword,
+                               'initiator' => null,
+                               'initiatorEmail' => null,
+                               'shareWith' => 'receiver@example.com',
+                       ]);
                        $this->mailer->expects($this->once())->method('send');
                } else {
                        $this->mailer->expects($this->never())->method('send');