Add homepage, tarifs, legal pages, navbar, footer and full test coverage

- Homepage: hero, how it works (buyer/organizer), features, CTA
- Tarifs: 3 plans (Gratuit, Basique 10€, Sur-mesure), JSON-LD Product
- Legal pages: mentions legales, CGU (tabs buyer/organizer), CGV, RGPD, cookies, hosting
- Navbar: neubrutalism style, logo liip, mobile menu, SEO attributes
- Footer: contact, description, legal links, tarifs
- Sitemap: add /tarifs and /sitemap-orgas-{page}.xml
- Liip Imagine: remove S3, webp format on all filters
- Tests: full coverage for all controllers, services, repositories
- Fix CSP: replace inline onclick with data-tab JS

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-19 00:01:58 +01:00
parent 4990e5cfe2
commit af8bbc24dc
30 changed files with 1631 additions and 39 deletions

View File

@@ -16,7 +16,7 @@ class MailerServiceTest extends TestCase
private UnsubscribeManager $unsubscribeManager;
private EntityManagerInterface $em;
private UrlGeneratorInterface $urlGenerator;
private MailerService $service;
private string $projectDir;
protected function setUp(): void
{
@@ -24,10 +24,27 @@ class MailerServiceTest extends TestCase
$this->unsubscribeManager = $this->createMock(UnsubscribeManager::class);
$this->em = $this->createMock(EntityManagerInterface::class);
$this->urlGenerator = $this->createMock(UrlGeneratorInterface::class);
$this->projectDir = sys_get_temp_dir().'/mailer_test_'.uniqid();
mkdir($this->projectDir.'/public', 0o777, true);
mkdir($this->projectDir.'/config/cert', 0o777, true);
}
$this->service = new MailerService(
protected function tearDown(): void
{
@unlink($this->projectDir.'/public/key.asc');
@unlink($this->projectDir.'/config/cert/certificate.pem');
@unlink($this->projectDir.'/config/cert/private-key.pem');
@rmdir($this->projectDir.'/config/cert');
@rmdir($this->projectDir.'/config');
@rmdir($this->projectDir.'/public');
@rmdir($this->projectDir);
}
private function createService(): MailerService
{
return new MailerService(
$this->bus,
sys_get_temp_dir(),
$this->projectDir,
'passphrase',
$this->urlGenerator,
$this->unsubscribeManager,
@@ -40,7 +57,7 @@ class MailerServiceTest extends TestCase
$this->unsubscribeManager->method('isUnsubscribed')->willReturn(true);
$this->bus->expects(self::never())->method('dispatch');
$this->service->sendEmail('user@example.com', 'Subject', '<p>Body</p>');
$this->createService()->sendEmail('user@example.com', 'Subject', '<p>Body</p>');
}
public function testSendEmailDoesNotSkipWhitelistedAddress(): void
@@ -51,7 +68,7 @@ class MailerServiceTest extends TestCase
$this->em->expects(self::once())->method('flush');
$this->bus->expects(self::once())->method('dispatch')->willReturn(new Envelope(new \stdClass()));
$this->service->sendEmail('contact@e-cosplay.fr', 'Subject', '<p>Body</p>');
$this->createService()->sendEmail('contact@e-cosplay.fr', 'Subject', '<p>Body</p>');
}
public function testSendEmailDispatchesForNonUnsubscribedUser(): void
@@ -63,15 +80,61 @@ class MailerServiceTest extends TestCase
$this->em->expects(self::once())->method('flush');
$this->bus->expects(self::once())->method('dispatch')->willReturn(new Envelope(new \stdClass()));
$this->service->sendEmail('user@example.com', 'Test', '<p>Content</p>');
$this->createService()->sendEmail('user@example.com', 'Test', '<p>Content</p>');
}
public function testSendEmailWithoutUnsubscribeHeaders(): void
{
$this->urlGenerator->method('generate')->willReturn('https://example.com/url');
$this->em->expects(self::once())->method('persist');
$this->em->expects(self::once())->method('flush');
$this->bus->expects(self::once())->method('dispatch')->willReturn(new Envelope(new \stdClass()));
$this->service->sendEmail('user@example.com', 'Test', '<p>Content</p>', withUnsubscribe: false);
$this->createService()->sendEmail('user@example.com', 'Test', '<p>Content</p>', withUnsubscribe: false);
}
public function testSendEmailWithReplyTo(): void
{
$this->unsubscribeManager->method('isUnsubscribed')->willReturn(false);
$this->unsubscribeManager->method('generateToken')->willReturn('token');
$this->urlGenerator->method('generate')->willReturn('https://example.com/url');
$this->em->expects(self::once())->method('persist');
$this->em->expects(self::once())->method('flush');
$this->bus->expects(self::once())->method('dispatch')->willReturn(new Envelope(new \stdClass()));
$this->createService()->sendEmail('user@example.com', 'Test', '<p>Content</p>', replyTo: 'reply@example.com');
}
public function testSendEmailWithAttachments(): void
{
$tmpFile = $this->projectDir.'/public/test.txt';
file_put_contents($tmpFile, 'test content');
$this->unsubscribeManager->method('isUnsubscribed')->willReturn(false);
$this->unsubscribeManager->method('generateToken')->willReturn('token');
$this->urlGenerator->method('generate')->willReturn('https://example.com/url');
$this->em->expects(self::once())->method('persist');
$this->em->expects(self::once())->method('flush');
$this->bus->expects(self::once())->method('dispatch')->willReturn(new Envelope(new \stdClass()));
$this->createService()->sendEmail('user@example.com', 'Test', '<p>Content</p>', attachments: [
['path' => $tmpFile, 'name' => 'test.txt'],
]);
@unlink($tmpFile);
}
public function testSendAttachesPublicKey(): void
{
file_put_contents($this->projectDir.'/public/key.asc', 'fake-pgp-key');
$this->unsubscribeManager->method('isUnsubscribed')->willReturn(false);
$this->unsubscribeManager->method('generateToken')->willReturn('token');
$this->urlGenerator->method('generate')->willReturn('https://example.com/url');
$this->em->expects(self::once())->method('persist');
$this->em->expects(self::once())->method('flush');
$this->bus->expects(self::once())->method('dispatch')->willReturn(new Envelope(new \stdClass()));
$this->createService()->sendEmail('user@example.com', 'Test', '<p>Content</p>');
}
}

View File

@@ -44,6 +44,27 @@ class MeilisearchServiceTest extends TestCase
self::assertFalse($this->service->indexExists('events'));
}
public function testCreateIndexIfNotExistsCreatesWhenMissing(): void
{
$this->httpClient->method('request')->willThrowException(new \RuntimeException('not found'));
$this->bus->expects(self::once())
->method('dispatch')
->with(self::callback(fn (MeilisearchMessage $m) => 'createIndex' === $m->action))
->willReturn(new Envelope(new \stdClass()));
$this->service->createIndexIfNotExists('events');
}
public function testCreateIndexIfNotExistsSkipsWhenExists(): void
{
$response = $this->createMock(ResponseInterface::class);
$response->method('getStatusCode')->willReturn(200);
$this->httpClient->method('request')->willReturn($response);
$this->bus->expects(self::never())->method('dispatch');
$this->service->createIndexIfNotExists('events');
}
public function testCreateIndexDispatchesMessage(): void
{
$this->bus->expects(self::once())
@@ -75,20 +96,73 @@ class MeilisearchServiceTest extends TestCase
$this->service->addDocuments('events', $docs);
}
public function testUpdateDocumentsDispatchesMessage(): void
{
$docs = [['id' => 1, 'title' => 'Updated']];
$this->bus->expects(self::once())
->method('dispatch')
->with(self::callback(fn (MeilisearchMessage $m) => 'updateDocuments' === $m->action && $m->payload['documents'] === $docs))
->willReturn(new Envelope(new \stdClass()));
$this->service->updateDocuments('events', $docs);
}
public function testDeleteDocumentDispatchesMessage(): void
{
$this->bus->expects(self::once())
->method('dispatch')
->with(self::callback(fn (MeilisearchMessage $m) => 'deleteDocument' === $m->action && 42 === $m->payload['documentId']))
->willReturn(new Envelope(new \stdClass()));
$this->service->deleteDocument('events', 42);
}
public function testDeleteDocumentsDispatchesMessage(): void
{
$ids = [1, 2, 3];
$this->bus->expects(self::once())
->method('dispatch')
->with(self::callback(fn (MeilisearchMessage $m) => 'deleteDocuments' === $m->action && $m->payload['ids'] === $ids))
->willReturn(new Envelope(new \stdClass()));
$this->service->deleteDocuments('events', $ids);
}
public function testUpdateSettingsDispatchesMessage(): void
{
$settings = ['filterableAttributes' => ['status']];
$this->bus->expects(self::once())
->method('dispatch')
->with(self::callback(fn (MeilisearchMessage $m) => 'updateSettings' === $m->action && $m->payload['settings'] === $settings))
->willReturn(new Envelope(new \stdClass()));
$this->service->updateSettings('events', $settings);
}
public function testSearchMakesPostRequest(): void
{
$response = $this->createMock(ResponseInterface::class);
$response->method('getStatusCode')->willReturn(200);
$response->method('toArray')->willReturn(['hits' => []]);
$this->httpClient->method('request')
->with('POST', self::stringContains('/indexes/events/search'), self::anything())
->willReturn($response);
$this->httpClient->method('request')->willReturn($response);
$result = $this->service->search('events', 'test');
self::assertArrayHasKey('hits', $result);
}
public function testGetDocumentReturnsArray(): void
{
$response = $this->createMock(ResponseInterface::class);
$response->method('getStatusCode')->willReturn(200);
$response->method('toArray')->willReturn(['id' => 1, 'title' => 'Event']);
$this->httpClient->method('request')->willReturn($response);
$result = $this->service->getDocument('events', 1);
self::assertSame(1, $result['id']);
}
public function testRequestReturnsEmptyArrayOn204(): void
{
$response = $this->createMock(ResponseInterface::class);

View File

@@ -79,4 +79,18 @@ class UnsubscribeManagerTest extends TestCase
$data = json_decode(file_get_contents($this->tempDir.'/var/unsubscribed.json'), true);
self::assertCount(1, $data);
}
public function testUnsubscribeCreatesDirWhenMissing(): void
{
$dir = sys_get_temp_dir().'/unsubscribe_nodir_'.uniqid();
$manager = new UnsubscribeManager($dir, 'secret');
$manager->unsubscribe('user@example.com');
self::assertTrue($manager->isUnsubscribed('user@example.com'));
@unlink($dir.'/var/unsubscribed.json');
@rmdir($dir.'/var');
@rmdir($dir);
}
}