Skip to content
Snippets Groups Projects
Unverified Commit b0ebf278 authored by Christoph Wurst's avatar Christoph Wurst
Browse files

Add an integration test for saving a draft

parent f8ed3e36
No related branches found
No related tags found
No related merge requests found
......@@ -103,7 +103,7 @@ class MailTransmission implements IMailTransmission {
/**
* @param NewMessageData $message
* @param type $draftUID
* @return type
* @return int
* @throws ServiceException
*/
public function saveDraft(NewMessageData $message, $draftUID = null) {
......
......@@ -195,6 +195,8 @@ trait ImapTest {
}
/**
* Assert that a mailbox has a certain number of messages in it
*
* @param int $number
* @param string $mailbox
*/
......@@ -203,7 +205,17 @@ trait ImapTest {
$query = new Horde_Imap_Client_Fetch_Query();
$query->uid();
$this->assertSame($number, $client->fetch($mailbox, $query)->count());
$this->assertSame($number, $client->fetch($mailbox, $query)->count(), "wrong number of messages in mailbox <$mailbox>");
}
/**
* Assert that the test account has a certain mailbox
*
* @param string $mailbox
*/
public function assertMailboxExists($mailbox) {
$mailboxes = $this->getMailboxes();
$this->assertArrayHasKey($mailbox, $mailboxes);
}
}
......@@ -32,13 +32,14 @@ use OCA\Mail\Service\Attachment\UploadedFile;
use OCA\Mail\Service\AutoCompletion\AddressCollector;
use OCA\Mail\Service\Logger;
use OCA\Mail\Service\MailTransmission;
use OCA\Mail\Tests\Integration\Framework\ImapTest;
use OCA\Mail\Tests\Integration\Framework\TestUser;
use OCA\Mail\Tests\Integration\TestCase;
use OCP\IUser;
class MailTransmissionIntegrationTest extends TestCase {
use TestUser;
use ImapTest, TestUser;
/** @var Account */
private $account;
......@@ -71,7 +72,7 @@ class MailTransmissionIntegrationTest extends TestCase {
]));
$this->attachmentService = OC::$server->query(IAttachmentService::class);
$this->user = $this->createTestUser();
$userFolder = \OC::$server->getUserFolder($this->user->getUID());
$userFolder = OC::$server->getUserFolder($this->user->getUID());
$this->transmission = new MailTransmission(OC::$server->query(AddressCollector::class), $userFolder, $this->attachmentService, OC::$server->query(Logger::class));
}
......@@ -110,4 +111,13 @@ class MailTransmissionIntegrationTest extends TestCase {
$this->transmission->sendMessage($this->user->getUID(), $message, $reply);
}
public function testSaveNewDraft() {
$message = NewMessageData::fromRequest($this->account, 'recipient@domain.com', null, null, 'greetings', 'hello there', []);
$this->transmission->saveDraft($message);
// There should be a new mailbox …
$this->assertMailboxExists('Drafts');
// … and it should have exactly one message
$this->assertMessageCount(1, 'Drafts');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment