[Web][Tests] Add mailbox group, identity sync, auth, Dovecot and SOGo module tests

This commit is contained in:
FreddleSpl0it committed 2026-10-27 10:15:00 +01:00
1 parent 2c5718c9c9
commit ad86403b87
19 files changed
+1997

No files matched your search

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace Mailcow\Tests\MailboxGroup\Service;
use Mailcow\Dovecot\Service\DovecotService;
use Mailcow\MailboxGroup\Repository\GroupRepository;
use Mailcow\MailboxGroup\Service\ChangeEffects;
use Mailcow\MailboxGroup\Service\TemplateService;
use Mailcow\Sogo\Service\SogoService;
use PHPUnit\Framework\TestCase;
class ChangeEffectsTest extends TestCase
{
public function testCachesAreFlushedForTheWritesOfTheRepository(): void
{
$repo = $this->createMock(GroupRepository::class);
$repo->method('takeEffects')->willReturn(['members' => ['a@example.org'], 'sogo_acl' => true]);
$legacy = $this->createMock(SogoService::class);
$legacy->expects($this->once())->method('refreshStaticView')->with(['b@example.org']);
$legacy->expects($this->once())->method('flushCache');
$dovecot = $this->createMock(DovecotService::class);
$dovecot->expects($this->once())->method('flushAuthCache')->with(['a@example.org']);
$templates = $this->createMock(TemplateService::class);
$templates->method('applyChanged')->willReturn([]);
(new ChangeEffects($templates, $legacy, $repo, $dovecot))->apply(['b@example.org'], []);
}
public function testSogoCacheStaysWithoutAclChanges(): void
{
$repo = $this->createMock(GroupRepository::class);
$repo->method('takeEffects')->willReturn(['members' => [], 'sogo_acl' => false]);
$legacy = $this->createMock(SogoService::class);
$legacy->expects($this->never())->method('flushCache');
$templates = $this->createMock(TemplateService::class);
$templates->method('applyChanged')->willReturn([]);
(new ChangeEffects($templates, $legacy, $repo, $this->createMock(DovecotService::class)))->apply([], []);
}
}