feat(mail) : ImapMailProvider — implémentation complète MailProviderInterface

This commit is contained in:
2026-05-19 23:35:12 +02:00
parent b5b4288cc0
commit b546f528df
2 changed files with 406 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php
declare(strict_types=1);
namespace App\Tests\Unit\Mail;
use App\Entity\MailConfiguration;
use App\Mail\Exception\MailProviderException;
use App\Mail\ImapMailProvider;
use App\Repository\MailConfigurationRepository;
use App\Service\TokenEncryptor;
use PHPUnit\Framework\TestCase;
use Psr\Log\NullLogger;
/**
* @internal
*/
class ImapMailProviderTest extends TestCase
{
public function testThrowsWhenConfigDisabled(): void
{
$config = new MailConfiguration();
$config->setEnabled(false);
$repo = $this->createMock(MailConfigurationRepository::class);
$repo->method('findSingleton')->willReturn($config);
$provider = new ImapMailProvider($repo, $this->makeEncryptor(), new NullLogger());
$this->expectException(MailProviderException::class);
$provider->listFolders();
}
public function testThrowsWhenConfigMissing(): void
{
$repo = $this->createMock(MailConfigurationRepository::class);
$repo->method('findSingleton')->willReturn(null);
$provider = new ImapMailProvider($repo, $this->makeEncryptor(), new NullLogger());
$this->expectException(MailProviderException::class);
$provider->listFolders();
}
private function makeEncryptor(): TokenEncryptor
{
return new TokenEncryptor(sodium_bin2hex(random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES)));
}
}