Admin panel (/admin, ROLE_ROOT): - Dashboard with CA HT Global/Commission cards and Meilisearch sync button - Buyers page with search (Meilisearch), create form, pagination (KnpPaginator) - Buyer actions: resend verification, force verify, reset password, delete - Organizers page with tabs (pending/approved), approve/reject with emails - Neo-brutalist design matching main site theme - Vite admin entry point with dedicated SCSS - CSP-compatible confirm dialogs via data-confirm attributes Meilisearch integration: - Auto-index buyers on email verification - Remove from index on buyer deletion - Manual sync button on dashboard - Search bar on buyers page - Add Meilisearch service to CI/SonarQube workflows - Add MEILISEARCH env vars to .env.test - Fix MeilisearchMessageHandler infinite loop: use request() directly instead of service methods that re-dispatch messages Email templates: - Redesign base email template to neo-brutalist style (borders, shadows, yellow footer) - Add E-Cosplay logo, "E-Ticket solution proposee par e-cosplay.fr" - Add admin_reset_password, organizer_approved, organizer_rejected templates Other: - Install knplabs/knp-paginator-bundle - Add ^/admin access_control for ROLE_ROOT in security.yaml - Update site footer with E-Ticket branding - 18 admin tests, updated MeilisearchMessageHandler tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
95 lines
3.1 KiB
PHP
95 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\MessageHandler;
|
|
|
|
use App\Message\MeilisearchMessage;
|
|
use App\MessageHandler\MeilisearchMessageHandler;
|
|
use App\Service\MeilisearchService;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class MeilisearchMessageHandlerTest extends TestCase
|
|
{
|
|
private MeilisearchService $meilisearch;
|
|
private MeilisearchMessageHandler $handler;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->meilisearch = $this->createMock(MeilisearchService::class);
|
|
$this->handler = new MeilisearchMessageHandler($this->meilisearch);
|
|
}
|
|
|
|
public function testHandleCreateIndex(): void
|
|
{
|
|
$this->meilisearch->expects(self::once())
|
|
->method('request')
|
|
->with('POST', '/indexes', ['uid' => 'events', 'primaryKey' => 'uid']);
|
|
|
|
($this->handler)(new MeilisearchMessage('createIndex', 'events', ['primaryKey' => 'uid']));
|
|
}
|
|
|
|
public function testHandleDeleteIndex(): void
|
|
{
|
|
$this->meilisearch->expects(self::once())
|
|
->method('request')
|
|
->with('DELETE', '/indexes/events');
|
|
|
|
($this->handler)(new MeilisearchMessage('deleteIndex', 'events'));
|
|
}
|
|
|
|
public function testHandleAddDocuments(): void
|
|
{
|
|
$docs = [['id' => 1]];
|
|
$this->meilisearch->expects(self::once())
|
|
->method('request')
|
|
->with('POST', '/indexes/events/documents', $docs);
|
|
|
|
($this->handler)(new MeilisearchMessage('addDocuments', 'events', ['documents' => $docs]));
|
|
}
|
|
|
|
public function testHandleUpdateDocuments(): void
|
|
{
|
|
$docs = [['id' => 1, 'title' => 'Updated']];
|
|
$this->meilisearch->expects(self::once())
|
|
->method('request')
|
|
->with('PUT', '/indexes/events/documents', $docs);
|
|
|
|
($this->handler)(new MeilisearchMessage('updateDocuments', 'events', ['documents' => $docs]));
|
|
}
|
|
|
|
public function testHandleDeleteDocument(): void
|
|
{
|
|
$this->meilisearch->expects(self::once())
|
|
->method('request')
|
|
->with('DELETE', '/indexes/events/documents/42');
|
|
|
|
($this->handler)(new MeilisearchMessage('deleteDocument', 'events', ['documentId' => 42]));
|
|
}
|
|
|
|
public function testHandleDeleteDocuments(): void
|
|
{
|
|
$this->meilisearch->expects(self::once())
|
|
->method('request')
|
|
->with('POST', '/indexes/events/documents/delete-batch', [1, 2, 3]);
|
|
|
|
($this->handler)(new MeilisearchMessage('deleteDocuments', 'events', ['ids' => [1, 2, 3]]));
|
|
}
|
|
|
|
public function testHandleUpdateSettings(): void
|
|
{
|
|
$settings = ['searchableAttributes' => ['title']];
|
|
$this->meilisearch->expects(self::once())
|
|
->method('request')
|
|
->with('PATCH', '/indexes/events/settings', $settings);
|
|
|
|
($this->handler)(new MeilisearchMessage('updateSettings', 'events', ['settings' => $settings]));
|
|
}
|
|
|
|
public function testUnknownActionThrowsException(): void
|
|
{
|
|
$this->expectException(\InvalidArgumentException::class);
|
|
$this->expectExceptionMessage('Unknown action: invalid');
|
|
|
|
($this->handler)(new MeilisearchMessage('invalid', 'events'));
|
|
}
|
|
}
|