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>2019-04-15 23:27:15 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2019-04-16 14:47:38 +0300
commit2725e5c121fd3422987c52a31f64787bef8ff5a6 (patch)
tree0b43d0e74c8c3b39834fea2fbbc6b971b551b4f6 /tests
parent905cca88f2dd37d448eac7ab67e76c892de15162 (diff)
Sort mailbox and build their hierarchy on the client-side
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/IMAP/FolderMapperTest.php87
-rw-r--r--tests/IMAP/MailboxPrefixDetectorTest.php115
-rw-r--r--tests/Service/MailManagerTest.php16
3 files changed, 0 insertions, 218 deletions
diff --git a/tests/IMAP/FolderMapperTest.php b/tests/IMAP/FolderMapperTest.php
index 2bbb0131f..4c2a0dc2e 100644
--- a/tests/IMAP/FolderMapperTest.php
+++ b/tests/IMAP/FolderMapperTest.php
@@ -95,52 +95,6 @@ class FolderMapperTest extends TestCase {
$this->assertEquals($expected, $folders);
}
- public function testBuildHierarchyWithoutPrefix() {
- $account = $this->createMock(Account::class);
- $folder1 = new Folder($account, new Horde_Imap_Client_Mailbox('test'), [], '.');
- $folder2 = new Folder($account, new Horde_Imap_Client_Mailbox('test.sub'), [], '.');
- $folder3 = new Folder($account, new Horde_Imap_Client_Mailbox('test.sub.sub'), [], '.');
- $folders = [
- clone $folder1,
- clone $folder2,
- clone $folder3,
- ];
- $folder1->addFolder($folder2);
- $folder1->addFolder($folder3);
- $expected = [
- $folder1,
- ];
-
- $result = $this->mapper->buildFolderHierarchy($folders, false);
-
- $this->assertEquals($expected, $result);
- }
-
- public function testBuildHierarchyWithPrefix() {
- $account = $this->createMock(Account::class);
- $folder1 = new Folder($account, new Horde_Imap_Client_Mailbox('INBOX'), [], '.');
- $folder2 = new Folder($account, new Horde_Imap_Client_Mailbox('INBOX.sub'), [], '.');
- $folder3 = new Folder($account, new Horde_Imap_Client_Mailbox('INBOX.sub.sub'), [], '.');
- $folder4 = new Folder($account, new Horde_Imap_Client_Mailbox('INBOX.sub.sub.sub'), [], '.');
- $folders = [
- clone $folder1,
- clone $folder2,
- clone $folder3,
- clone $folder4,
- ];
- $folder2->addFolder($folder3);
- $folder2->addFolder($folder4);
- $expected = [
- $folder1,
- $folder2,
- ];
-
- $result = $this->mapper->buildFolderHierarchy($folders, true);
-
- $this->assertCount(count($expected), $result);
- $this->assertEquals($expected, $result);
- }
-
public function testGetFoldersStatus() {
$folders = [
$this->createMock(Folder::class),
@@ -252,45 +206,4 @@ class FolderMapperTest extends TestCase {
$this->mapper->detectFolderSpecialUse($folders);
}
- public function testSortFolders() {
- $account = $this->createMock(Account::class);
- $mailbox = $this->createMock(Horde_Imap_Client_Mailbox::class);
-
- $folder1 = new Folder($account, $mailbox, [], '.');
- $folder1->setDisplayName('Entwürfe');
- $folder1->addSpecialUse('drafts');
- $folder2 = new Folder($account, $mailbox, [], '.');
- $folder2->setDisplayName('Eingang');
- $folder2->addSpecialUse('inbox');
- $folder3 = new Folder($account, $mailbox, [], '.');
- $folder3->setDisplayName('Other 2');
- $folder4 = new Folder($account, $mailbox, [], '.');
- $folder4->setDisplayName('Other 1');
- $folder5 = new Folder($account, $mailbox, [], '.');
- $folder5->setDisplayName('Gesendete Elemente');
- $folder5->addSpecialUse('sent');
- $folder6 = new Folder($account, $mailbox, [], '.');
- $folder6->setDisplayName('Gesendet');
- $folder6->addSpecialUse('sent');
-
- $folders = [
- $folder1,
- $folder2,
- $folder3,
- $folder4,
- $folder5,
- $folder6,
- ];
-
- $this->mapper->sortFolders($folders);
-
- // Expected order: Inbox, Drafts, Sent1, Sent2, other 1, other 2
- $this->assertSame($folder2, $folders[0]);
- $this->assertSame($folder1, $folders[1]);
- $this->assertSame($folder6, $folders[2]);
- $this->assertSame($folder5, $folders[3]);
- $this->assertSame($folder4, $folders[4]);
- $this->assertSame($folder3, $folders[5]);
- }
-
}
diff --git a/tests/IMAP/MailboxPrefixDetectorTest.php b/tests/IMAP/MailboxPrefixDetectorTest.php
deleted file mode 100644
index a9cf154dc..000000000
--- a/tests/IMAP/MailboxPrefixDetectorTest.php
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-
-/**
- * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-namespace OCA\Mail\Tests\IMAP;
-
-use ChristophWurst\Nextcloud\Testing\TestCase;
-use OCA\Mail\Folder;
-use OCA\Mail\IMAP\MailboxPrefixDetector;
-use OCA\Mail\SearchFolder;
-
-class MailboxPrefixDetectorTest extends TestCase {
-
- /** @var MailboxPrefixDetector */
- private $detector;
-
- protected function setUp() {
- parent::setUp();
-
- $this->detector = new MailboxPrefixDetector();
- }
-
- public function testDetectWithPrefix() {
- $folder1 = $this->createMock(Folder::class);
- $folder2 = $this->createMock(Folder::class);
- $folder1->expects($this->once())
- ->method('getMailbox')
- ->willReturn('INBOX');
- $folder1->expects($this->once())
- ->method('getDelimiter')
- ->willReturn('.');
- $folder2->expects($this->once())
- ->method('getMailbox')
- ->willReturn('INBOX.Sent');
- $folder2->expects($this->once())
- ->method('getDelimiter')
- ->willReturn('.');
-
- $havePrefix = $this->detector->havePrefix([
- $folder1,
- $folder2,
- ]);
-
- $this->assertTrue($havePrefix);
- }
-
- public function testDetectWithoutPrefix() {
- $folder1 = $this->createMock(Folder::class);
- $folder2 = $this->createMock(Folder::class);
- $folder1->expects($this->once())
- ->method('getMailbox')
- ->willReturn('INBOX');
- $folder1->expects($this->once())
- ->method('getDelimiter')
- ->willReturn('.');
- $folder2->expects($this->once())
- ->method('getMailbox')
- ->willReturn('Sent');
- $folder2->expects($this->once())
- ->method('getDelimiter')
- ->willReturn('.');
-
- $havePrefix = $this->detector->havePrefix([
- $folder1,
- $folder2,
- ]);
-
- $this->assertFalse($havePrefix);
- }
-
- public function testDetectWithSearchFolder() {
- $folder1 = $this->createMock(Folder::class);
- $folder2 = $this->createMock(SearchFolder::class);
- $folder1->expects($this->any())
- ->method('getMailbox')
- ->willReturn('INBOX');
- $folder1->expects($this->any())
- ->method('getDelimiter')
- ->willReturn('.');
- $folder2->expects($this->any())
- ->method('getMailbox')
- ->willReturn('INBOX/Flagged');
- $folder2->expects($this->any())
- ->method('getDelimiter')
- ->willReturn('.');
-
- $havePrefix = $this->detector->havePrefix([
- $folder1,
- $folder2,
- ]);
-
- $this->assertTrue($havePrefix);
- }
-
-}
diff --git a/tests/Service/MailManagerTest.php b/tests/Service/MailManagerTest.php
index fa21ec853..4baeef815 100644
--- a/tests/Service/MailManagerTest.php
+++ b/tests/Service/MailManagerTest.php
@@ -26,7 +26,6 @@ use Horde_Imap_Client_Socket;
use OCA\Mail\Account;
use OCA\Mail\IMAP\FolderMapper;
use OCA\Mail\IMAP\IMAPClientFactory;
-use OCA\Mail\IMAP\MailboxPrefixDetector;
use OCA\Mail\IMAP\MessageMapper;
use OCA\Mail\IMAP\Sync\Request;
use OCA\Mail\IMAP\Sync\Response;
@@ -43,9 +42,6 @@ class MailManagerTest extends TestCase {
/** @var FolderMapper|PHPUnit_Framework_MockObject_MockObject */
private $folderMapper;
- /** @var MailboxPrefixDetector|PHPUnit_Framework_MockObject_MockObject */
- private $prefixDetector;
-
/** @var MessageMapper|PHPUnit_Framework_MockObject_MockObject */
private $messageMapper;
@@ -60,14 +56,12 @@ class MailManagerTest extends TestCase {
$this->imapClientFactory = $this->createMock(IMAPClientFactory::class);
$this->folderMapper = $this->createMock(FolderMapper::class);
- $this->prefixDetector = $this->createMock(MailboxPrefixDetector::class);
$this->messageMapper = $this->createMock(MessageMapper::class);
$this->sync = $this->createMock(Synchronizer::class);
$this->manager = new MailManager(
$this->imapClientFactory,
$this->folderMapper,
- $this->prefixDetector,
$this->sync,
$this->messageMapper
);
@@ -76,9 +70,6 @@ class MailManagerTest extends TestCase {
public function testGetFolders() {
$client = $this->createMock(Horde_Imap_Client_Socket::class);
$account = $this->createMock(Account::class);
- $this->prefixDetector->expects($this->once())
- ->method('havePrefix')
- ->willReturn(false);
$this->imapClientFactory->expects($this->once())
->method('getClient')
->willReturn($client);
@@ -96,13 +87,6 @@ class MailManagerTest extends TestCase {
$this->folderMapper->expects($this->once())
->method('detectFolderSpecialUse')
->with($this->equalTo($folders));
- $this->folderMapper->expects($this->once())
- ->method('sortFolders')
- ->with($this->equalTo($folders));
- $this->folderMapper->expects($this->once())
- ->method('buildFolderHierarchy')
- ->with($this->equalTo($folders))
- ->willReturn($folders);
$this->manager->getFolders($account);
}