Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions lib/IMAP/FolderMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ public function fetchFolderAcls(array $folders,
*/
public function getFoldersStatusAsObject(Horde_Imap_Client_Socket $client,
array $mailboxes): array {
$multiStatus = $client->status($mailboxes);

$statuses = [];
foreach ($multiStatus as $mailbox => $status) {
foreach ($mailboxes as $mailbox) {
$status = $client->status($mailbox);
try {
if (!isset($status['messages'], $status['unseen'])) {
throw new ServiceException('Could not fetch stats of mailbox: ' . $mailbox);
Expand All @@ -143,7 +142,7 @@ public function getFoldersStatusAsObject(Horde_Imap_Client_Socket $client,
$this->logger->warning($e->getMessage(), [
'exception' => $e,
'mailboxes' => $mailboxes,
'statuses' => $multiStatus,
'status' => $status,
]);
}
}
Expand Down
24 changes: 6 additions & 18 deletions tests/Unit/IMAP/FolderMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,10 @@ public function testGetFoldersStatusAsObject(): void {
$client = $this->createMock(Horde_Imap_Client_Socket::class);
$client->expects($this->once())
->method('status')
->with(['INBOX'])
->with('INBOX')
->willReturn([
'INBOX' => [
'messages' => 123,
'unseen' => 2,
],
'messages' => 123,
'unseen' => 2,
]);

$stats = $this->mapper->getFoldersStatusAsObject($client, ['INBOX']);
Expand All @@ -228,25 +226,15 @@ public function testGetFoldersStatusAsObjectNullStats(): void {
$client = $this->createMock(Horde_Imap_Client_Socket::class);
$client->expects($this->once())
->method('status')
->with(['INBOX'])
->with('INBOX')
->willReturn([
'INBOX' => [
'messages' => null,
'unseen' => 2,
],
'Company' => [
'messages' => 123,
'unseen' => 2,
],
'messages' => null,
'unseen' => 2,
]);

$stats = $this->mapper->getFoldersStatusAsObject($client, ['INBOX']);

self::assertArrayNotHasKey('INBOX', $stats);
self::assertArrayHasKey('Company', $stats);
$expected = new MailboxStats(123, 2);
self::assertEquals($expected, $stats['Company']);

}

public function testDetectSpecialUseFromAttributes() {
Expand Down
Loading