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

remove dead code and test folder sorting

parent 2d834e22
No related branches found
No related tags found
No related merge requests found
......@@ -351,29 +351,7 @@ class Account implements IAccount {
* @return array
*/
public function jsonSerialize() {
$folders = [];
$mailBoxes = $this->getMailboxes();
$mailBoxNames = array_map(function($mb) {
/** @var Mailbox $mb */
return $mb->getFolderId();
}, array_filter($mailBoxes, function($mb) {
/** @var Mailbox $mb */
return (!$mb instanceof SearchMailbox) && (!in_array('\noselect', $mb->attributes()));
}));
$status = $this->getImapConnection()->status($mailBoxNames);
foreach ($mailBoxes as $mailbox) {
$s = isset($status[$mailbox->getFolderId()]) ? $status[$mailbox->getFolderId()] : null;
$folders[] = $mailbox->serialize($this->getId(), $s);
}
$delimiter = reset($folders)['delimiter'];
return [
'id' => $this->getId(),
'email' => $this->getEMailAddress(),
'folders' => array_values($folders),
'specialFolders' => $this->getSpecialFoldersIds(),
'delimiter' => $delimiter,
];
throw new Exception('Not implemented');
}
/**
......
......@@ -49,22 +49,6 @@ class AccountTest extends AbstractTest {
];
}
/**
* @dataProvider providesMailBoxNames
* @param $name
*/
public function testListMailBoxes($name) {
$name = uniqid($name);
$this->createMailBox($name);
$mailBoxes = $this->getTestAccount()->jsonSerialize();
$this->assertInternalType('array', $mailBoxes);
$m = array_filter($mailBoxes['folders'], function($item) use ($name) {
return $item['name'] === $name;
});
$this->assertTrue(count($m) === 1);
}
/**
* @dataProvider providesMailBoxNames
* @param $name
......
......@@ -228,7 +228,61 @@ class FolderMapperTest extends TestCase {
}
public function testSortFolders() {
// TODO
$folder1 = $this->createMock(Folder::class);
$folder1->expects($this->any())
->method('getSpecialUse')
->willReturn(['drafts']);
$folder1->expects($this->any())
->method('getDisplayName')
->willReturn('Entwürfe');
$folder2 = $this->createMock(Folder::class);
$folder2->expects($this->any())
->method('getSpecialUse')
->willReturn(['inbox']);
$folder2->expects($this->any())
->method('getDisplayName')
->willReturn('Eingang');
$folder3 = $this->createMock(Folder::class);
$folder3->expects($this->any())
->method('getDisplayName')
->willReturn('Other 2');
$folder4 = $this->createMock(Folder::class);
$folder4->expects($this->any())
->method('getDisplayName')
->willReturn('Other 1');
$folder5 = $this->createMock(Folder::class);
$folder5->expects($this->any())
->method('getSpecialUse')
->willReturn(['sent']);
$folder5->expects($this->any())
->method('getDisplayName')
->willReturn('Gesendete Elemente');
$folder6 = $this->createMock(Folder::class);
$folder6->expects($this->any())
->method('getSpecialUse')
->willReturn(['sent']);
$folder6->expects($this->any())
->method('getDisplayName')
->willReturn('Gesendet');
$folders = [
$folder1,
$folder2,
$folder3,
$folder4,
$folder5,
$folder6,
];
$this->mapper->sortFolders($folders);
// Expected order: Inbox, Drafts, Sent1, Sent2, other
$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]);
}
}
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