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
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2022-03-25 13:37:57 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2022-04-07 19:34:32 +0300
commit9063c6e36e314c77401fa4be5abf02a41c0d0a57 (patch)
tree336be567876f3a792a2b6f091fddc820c89203bf /tests/Integration
parent2bbcbb9d59e30c87126f048d41c7030680c773d3 (diff)
Add a background worker job that flushes the outbox
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/Integration')
-rw-r--r--tests/Integration/Service/OutboxServiceIntegrationTest.php39
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/Integration/Service/OutboxServiceIntegrationTest.php b/tests/Integration/Service/OutboxServiceIntegrationTest.php
index 501433d16..cbfa17c13 100644
--- a/tests/Integration/Service/OutboxServiceIntegrationTest.php
+++ b/tests/Integration/Service/OutboxServiceIntegrationTest.php
@@ -37,6 +37,7 @@ use OCA\Mail\Db\MailAccount;
use OCA\Mail\Db\MailboxMapper;
use OCA\Mail\Db\MessageMapper;
use OCA\Mail\IMAP\IMAPClientFactory;
+use OCA\Mail\Service\AccountService;
use OCA\Mail\Service\Attachment\AttachmentService;
use OCA\Mail\Service\Attachment\AttachmentStorage;
use OCA\Mail\Service\OutboxService;
@@ -45,11 +46,13 @@ use OCA\Mail\Tests\Integration\Framework\ImapTest;
use OCA\Mail\Tests\Integration\Framework\ImapTestAccount;
use OCA\Mail\Tests\Integration\TestCase;
use OCP\AppFramework\Db\DoesNotExistException;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder;
use OCP\IServerContainer;
use OCP\IUser;
use Psr\Container\ContainerInterface;
+use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
class OutboxServiceIntegrationTest extends TestCase {
@@ -84,6 +87,12 @@ class OutboxServiceIntegrationTest extends TestCase {
/** @var Folder */
private $userFolder;
+ /** @var */
+ private $accountService;
+
+ /** @var ITimeFactory */
+ private $timeFactory;
+
protected function setUp(): void {
parent::setUp();
@@ -109,6 +118,8 @@ class OutboxServiceIntegrationTest extends TestCase {
$this->transmission = OC::$server->get(IMailTransmission::class);
$this->eventDispatcher = OC::$server->get(IEventDispatcher::class);
$this->clientFactory = OC::$server->get(IMAPClientFactory::class);
+ $this->accountService = OC::$server->get(AccountService::class);
+ $this->timeFactory = OC::$server->get(ITimeFactory::class);
$this->db = \OC::$server->getDatabaseConnection();
$qb = $this->db->getQueryBuilder();
@@ -121,7 +132,10 @@ class OutboxServiceIntegrationTest extends TestCase {
$this->attachmentService,
$this->eventDispatcher,
$this->clientFactory,
- $mailManager
+ $mailManager,
+ $this->accountService,
+ $this->timeFactory,
+ $this->createMock(LoggerInterface::class)
);
}
@@ -348,4 +362,27 @@ class OutboxServiceIntegrationTest extends TestCase {
$this->expectException(DoesNotExistException::class);
$this->outbox->getMessage($message->getId(), $this->user->getUID());
}
+
+ public function testSaveAndFlush(): void {
+ $message = new LocalMessage();
+ $message->setType(LocalMessage::TYPE_OUTGOING);
+ $message->setAccountId($this->account->getId());
+ $message->setSubject('subject');
+ $message->setBody('message');
+ $message->setHtml(true);
+ $message->setSendAt(100);
+
+ $to = [[
+ 'label' => 'Penny',
+ 'email' => 'library@stardewvalley.com'
+ ]];
+
+ $saved = $this->outbox->saveMessage(new Account($this->account), $message, $to, [], []);
+ $this->assertNotEmpty($saved->getRecipients());
+ $this->assertEmpty($saved->getAttachments());
+
+ $this->outbox->flush();
+ $this->expectException(DoesNotExistException::class);
+ $this->outbox->getMessage($saved->getId(), $this->user->getUID());
+ }
}