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>2018-02-15 11:49:58 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2018-02-15 12:39:20 +0300
commita5ddd8283386fd26d2ef1328803ece88662503ba (patch)
treebff6420a2315c6da6928654ca730c30fe9642259 /tests
parentd3cd693c520d3bba76ef1d41b673d19ccef4fd0a (diff)
Fix folder hierarchy for prefixed mailboxes
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/IMAP/FolderMapperTest.php (renamed from tests/Service/FolderMapperTest.php)31
1 files changed, 28 insertions, 3 deletions
diff --git a/tests/Service/FolderMapperTest.php b/tests/IMAP/FolderMapperTest.php
index e9c0647ac..2bbb0131f 100644
--- a/tests/Service/FolderMapperTest.php
+++ b/tests/IMAP/FolderMapperTest.php
@@ -19,7 +19,7 @@
*
*/
-namespace OCA\Mail\Tests\Service;
+namespace OCA\Mail\Tests\IMAP;
use Horde_Imap_Client;
use Horde_Imap_Client_Mailbox;
@@ -95,7 +95,7 @@ class FolderMapperTest extends TestCase {
$this->assertEquals($expected, $folders);
}
- public function testBuildHierarchy() {
+ 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'), [], '.');
@@ -111,11 +111,36 @@ class FolderMapperTest extends TestCase {
$folder1,
];
- $result = $this->mapper->buildFolderHierarchy($folders);
+ $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),