Skip to content
Merged
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
8 changes: 5 additions & 3 deletions lib/IMAP/MailboxSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,11 @@ private function syncMailboxStatus(mixed $mailboxes, ?string $personalNamespace,
return $mailbox->getName();
}, $syncStatus));
foreach ($syncStatus as $mailbox) {
$status = $statuses[$mailbox->getName()];
$mailbox->setMessages($status->getTotal());
$mailbox->setUnseen($status->getUnread());
$status = $statuses[$mailbox->getName()] ?? null;
if ($status !== null) {
$mailbox->setMessages($status->getTotal());
$mailbox->setUnseen($status->getUnread());
}
}
$this->atomic(function () use ($syncStatus) {
foreach ($syncStatus as $mailbox) {
Expand Down
10 changes: 7 additions & 3 deletions tests/Unit/IMAP/MailboxSyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function testSync(): void {
$folders = [
$this->createMock(Folder::class),
$this->createMock(Folder::class),
$this->createMock(Folder::class),
];
$status = [
'unseen' => 10,
Expand All @@ -133,24 +134,27 @@ public function testSync(): void {
$folders[0]->method('getMailbox')->willReturn('mb1');
$folders[1]->method('getStatus')->willReturn($status);
$folders[1]->method('getMailbox')->willReturn('mb2');
$folders[2]->method('getStatus')->willReturn($status);
$folders[2]->method('getMailbox')->willReturn('mb3');
$this->folderMapper->expects($this->once())
->method('getFolders')
->with($account, $client)
->willReturn($folders);
$this->folderMapper->expects($this->once())
->method('getFoldersStatusAsObject')
->with($client, self::equalToCanonicalizing(['mb1', 'mb2',]))
->with($client, self::equalToCanonicalizing(['mb1', 'mb2', 'mb3',]))
->willReturn([
'mb1' => new MailboxStats(1, 2),
'mb2' => new MailboxStats(1, 2),
/* no status for mb3 */
]);
$this->folderMapper->expects($this->once())
->method('detectFolderSpecialUse')
->with($folders);
$this->mailboxMapper->expects(self::exactly(2))
$this->mailboxMapper->expects(self::exactly(3))
->method('insert')
->willReturnArgument(0);
$this->mailboxMapper->expects(self::exactly(2))
$this->mailboxMapper->expects(self::exactly(3))
->method('update')
->willReturnArgument(0);
$this->dispatcher
Expand Down