feat: création boîte mail Esy-Mail lors de la création client

EsyMailService :
- createMailbox(email, password, quotaMb) : INSERT dans la table mailbox
  de la base esymail avec hash bcrypt (BLF-CRYPT compatible Dovecot)
- mailboxExists(email) : vérifie si l'adresse existe déjà
- isAvailable() : vérifie si ESYMAIL_DATABASE_URL est configuré
- Connexion DBAL directe vers la base esymail (séparée de l'EntityManager)

ClientsController :
- Ajout paramètre EsyMailService dans create()
- Ajout méthode createMailboxIfRequested() : vérifie checkbox, valide
  email/password, vérifie existence, crée la boîte avec quota choisi
- Flash success/error selon le résultat

Template admin/clients/create.html.twig :
- Section "Messagerie Esy-Mail" avec checkbox toggle
- Champs : adresse email, mot de passe (min 8 chars), quota (1/2/5/10 Go)
- Masqué par défaut, affiché au clic sur la checkbox

Configuration :
- .env : ajout ESYMAIL_DATABASE_URL (vide par défaut)
- .env.local : connexion vers database:5432/esymail

Tests mis à jour avec EsyMailService stubé dans tous les appels create()

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-04-03 16:50:50 +02:00
parent 5c4576ca27
commit 7a7796c090
5 changed files with 177 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ use App\Controller\Admin\ClientsController;
use App\Entity\Customer;
use App\Entity\User;
use App\Repository\CustomerRepository;
use App\Service\EsyMailService;
use App\Service\MeilisearchService;
use App\Service\UserManagementService;
use Doctrine\ORM\EntityManagerInterface;
@@ -73,7 +74,7 @@ class ClientsControllerTest extends TestCase
$userService = $this->createStub(UserManagementService::class);
$logger = $this->createStub(LoggerInterface::class);
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, 'sk_test_***');
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, $this->createStub(EsyMailService::class), 'sk_test_***');
$this->assertInstanceOf(Response::class, $response);
}
@@ -93,7 +94,7 @@ class ClientsControllerTest extends TestCase
$userService->method('createBaseUser')->willThrowException(new \InvalidArgumentException('Champs requis'));
$logger = $this->createStub(LoggerInterface::class);
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, 'sk_test_***');
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, $this->createStub(EsyMailService::class), 'sk_test_***');
$this->assertInstanceOf(Response::class, $response);
}
@@ -113,7 +114,7 @@ class ClientsControllerTest extends TestCase
$userService->method('createBaseUser')->willThrowException(new \RuntimeException('DB error'));
$logger = $this->createStub(LoggerInterface::class);
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, 'sk_test_***');
$response = $controller->create($request, $repo, $em, $meilisearch, $userService, $logger, $this->createStub(EsyMailService::class), 'sk_test_***');
$this->assertInstanceOf(Response::class, $response);
}
@@ -249,6 +250,7 @@ class ClientsControllerTest extends TestCase
$this->createStub(MeilisearchService::class),
$userService,
$this->createStub(LoggerInterface::class),
$this->createStub(EsyMailService::class),
'',
);
$this->assertSame(302, $response->getStatusCode());
@@ -286,6 +288,7 @@ class ClientsControllerTest extends TestCase
$this->createStub(MeilisearchService::class),
$userService,
$this->createStub(LoggerInterface::class),
$this->createStub(EsyMailService::class),
'sk_test_***',
);
$this->assertSame(302, $response->getStatusCode());
@@ -326,6 +329,7 @@ class ClientsControllerTest extends TestCase
$meilisearch,
$userService,
$this->createStub(LoggerInterface::class),
$this->createStub(EsyMailService::class),
'',
);
$this->assertSame(302, $response->getStatusCode());