Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-12-16 22:17:19 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-12-17 10:38:10 +0300
commitca1b379a5fb6579e4da818804adbf6685255a2ae (patch)
tree71598923c3473afb0de3f601735bc98bf4a32c70 /tests
parentec3e82831086eaac68af0036f81a4f0502255c6e (diff)
Add forward as attachment
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Service/MailTransmissionTest.php69
1 files changed, 68 insertions, 1 deletions
diff --git a/tests/Unit/Service/MailTransmissionTest.php b/tests/Unit/Service/MailTransmissionTest.php
index cfdaca35a..ef37d9c2b 100644
--- a/tests/Unit/Service/MailTransmissionTest.php
+++ b/tests/Unit/Service/MailTransmissionTest.php
@@ -165,6 +165,73 @@ class MailTransmissionTest extends TestCase {
$this->transmission->sendMessage($messageData, null, $alias);
}
+ public function testSendNewMessageWithMessageAsAttachment() {
+ $mailAccount = new MailAccount();
+ $mailAccount->setUserId('testuser');
+ $mailAccount->setSentMailboxId(123);
+
+ /** @var Account|MockObject $account */
+ $account = $this->createMock(Account::class);
+ $account->method('getMailAccount')->willReturn($mailAccount);
+ $account->method('getName')->willReturn('Test User');
+ $account->method('getEMailAddress')->willReturn('test@user');
+
+ $originalAttachment = [
+ [
+ 'fileName' => 'Test attachment',
+ 'id' => '123456',
+ 'type' => 'message'
+ ]
+ ];
+
+ $messageData = NewMessageData::fromRequest($account, 'to@d.com', '', '', 'sub', 'bod', $originalAttachment);
+
+ $message = new Message();
+ $account->expects($this->once())
+ ->method('newMessage')
+ ->willReturn($message);
+ $transport = $this->createMock(Horde_Mail_Transport::class);
+ $this->smtpClientFactory->expects($this->once())
+ ->method('create')
+ ->with($account)
+ ->willReturn($transport);
+
+ $attachmentMessage = new DbMessage();
+ $attachmentMessage->setMailboxId(1234);
+ $attachmentMessage->setUid(11);
+
+ $mailbox = new DbMailbox();
+ $mailbox->setAccountId(22);
+ $mailbox->setName('mock');
+
+ $client = $this->createMock(Horde_Imap_Client_Socket::class);
+ $this->imapClientFactory->expects($this->exactly(2))
+ ->method('getClient')
+ ->with($account)
+ ->willReturn($client);
+
+ $this->mailManager->expects($this->once())
+ ->method('getMessage')
+ ->with($mailAccount->getUserId(), 123456)
+ ->willReturn($attachmentMessage);
+ $this->mailManager->expects($this->once())
+ ->method('getMailbox')
+ ->with($mailAccount->getUserId(), $attachmentMessage->getMailboxId())
+ ->willReturn($mailbox);
+
+ $source = 'da message';
+ $this->messageMapper->expects($this->once())
+ ->method('getFullText')
+ ->with(
+ $this->imapClientFactory->getClient($account),
+ $mailbox->getName(),
+ 11
+ )
+ ->willReturn($source);
+
+ $this->transmission->sendMessage($messageData, null);
+ }
+
public function testSendNewMessageWithAttachmentsFromEmail() {
$mailAccount = new MailAccount();
$mailAccount->setUserId('testuser');
@@ -181,7 +248,7 @@ class MailTransmissionTest extends TestCase {
'fileName' => 'Test attachment',
'id' => '2.2',
'messageId' => '100',
- 'type' => 'mail'
+ 'type' => 'message-attachment'
]
];