Files
e-ticket/tests/Controller/HomeControllerTest.php
Serreau Jovann 198d684fb8 Add organizer pages, SEO breadcrumbs, Open Graph, homepage redesign, and infrastructure updates
- Add public organizers list page (/organisateurs) with neo-brutalist card grid, social icons, and logo display
- Add organizer detail page (/organisateur/{id}-{slug}) with company info, SIRET, email, address, social links, and events placeholder
- Add slug-based URLs with 301 redirect on wrong slug, getSlug() method on User entity
- Add "Voir les evenements" button on organizer cards linking to detail page
- Add JSON-LD BreadcrumbList to all 17 pages that were missing breadcrumbs (login, forgot_password, register_success, email_verified, legal/*, attestation/*, account/*)
- Add Open Graph meta tags (og:title, og:description, og:image, og:type, og:locale, og:site_name) in base.html.twig with automatic inheritance from title/description blocks
- Add og:image with organizer logo on detail page
- Update sitemap: add /organisateurs to sitemap-main, generate organizer detail URLs in sitemap-orgas with logo images
- Update navbar to highlight "Organisateurs" on detail pages
- Redesign homepage with hero section, marquee, stats counters, how-it-works, and CTA sections
- Add Tailwind v4 @source "../templates" directive to app.scss and admin.scss
- Migrate Flysystem from S3 to local storage (uploads/events, uploads/logos)
- Update Liip Imagine config with FormatExtensionResolver for webp conversion
- Add User entity social fields (website, facebook, instagram, twitter, tiktok), logo upload (Vich), __serialize/__unserialize for session safety
- Add account page settings tab with profile, logo upload, and social media for organizers
- Add Stripe Connect status display and sub-account management in account page
- Delete WebpExtensionSubscriber (replaced by FormatExtensionResolver)
- Add migration for social fields and logo columns
- Add deploy.yml chmod tasks for uploads directories
- Add HomeController tests (detail success, wrong slug redirect, 404 cases)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-20 10:44:31 +01:00

140 lines
4.7 KiB
PHP

<?php
namespace App\Tests\Controller;
use App\Entity\User;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class HomeControllerTest extends WebTestCase
{
public function testIndexReturnsSuccess(): void
{
$client = static::createClient();
$client->request('GET', '/');
self::assertResponseIsSuccessful();
}
public function testTarifsReturnsSuccess(): void
{
$client = static::createClient();
$client->request('GET', '/tarifs');
self::assertResponseIsSuccessful();
}
public function testOrganizersReturnsSuccess(): void
{
$client = static::createClient();
$client->request('GET', '/organisateurs');
self::assertResponseIsSuccessful();
}
public function testOrganizerDetailReturnsSuccess(): void
{
$client = static::createClient();
$em = static::getContainer()->get(EntityManagerInterface::class);
$organizer = $em->getRepository(User::class)->findOneBy([]);
$found = false;
if ($organizer) {
foreach ($em->getRepository(User::class)->findAll() as $user) {
if (\in_array('ROLE_ORGANIZER', $user->getRoles(), true) && $user->isApproved()) {
$organizer = $user;
$found = true;
break;
}
}
}
if (!$found) {
$organizer = new User();
$organizer->setEmail('test-orga-detail@example.com');
$organizer->setFirstName('Test');
$organizer->setLastName('Orga');
$organizer->setPassword('hashed');
$organizer->setRoles(['ROLE_ORGANIZER']);
$organizer->setIsApproved(true);
$organizer->setIsVerified(true);
$organizer->setCompanyName('Asso Test');
$organizer->setSiret('12345678901234');
$em->persist($organizer);
$em->flush();
}
$client->request('GET', '/organisateur/' . $organizer->getId() . '-' . $organizer->getSlug());
self::assertResponseIsSuccessful();
self::assertSelectorTextContains('h1', $organizer->getCompanyName() ?? $organizer->getFirstName());
}
public function testOrganizerDetailRedirectsOnWrongSlug(): void
{
$client = static::createClient();
$em = static::getContainer()->get(EntityManagerInterface::class);
$organizer = new User();
$organizer->setEmail('test-orga-slug-' . uniqid() . '@example.com');
$organizer->setFirstName('Slug');
$organizer->setLastName('Test');
$organizer->setPassword('hashed');
$organizer->setRoles(['ROLE_ORGANIZER']);
$organizer->setIsApproved(true);
$organizer->setIsVerified(true);
$organizer->setCompanyName('Mon Asso');
$em->persist($organizer);
$em->flush();
$client->request('GET', '/organisateur/' . $organizer->getId() . '-mauvais-slug');
self::assertResponseRedirects('/organisateur/' . $organizer->getId() . '-mon-asso', 301);
}
public function testOrganizerDetailNotFoundReturns404(): void
{
$client = static::createClient();
$client->request('GET', '/organisateur/999999-inexistant');
self::assertResponseStatusCodeSame(404);
}
public function testOrganizerDetailNonApprovedReturns404(): void
{
$client = static::createClient();
$em = static::getContainer()->get(EntityManagerInterface::class);
$organizer = new User();
$organizer->setEmail('test-orga-noapprove-' . uniqid() . '@example.com');
$organizer->setFirstName('Test');
$organizer->setLastName('NonApproved');
$organizer->setPassword('hashed');
$organizer->setRoles(['ROLE_ORGANIZER']);
$organizer->setIsApproved(false);
$organizer->setIsVerified(true);
$em->persist($organizer);
$em->flush();
$client->request('GET', '/organisateur/' . $organizer->getId() . '-' . $organizer->getSlug());
self::assertResponseStatusCodeSame(404);
}
public function testOrganizerDetailBuyerReturns404(): void
{
$client = static::createClient();
$em = static::getContainer()->get(EntityManagerInterface::class);
$buyer = new User();
$buyer->setEmail('test-buyer-detail-' . uniqid() . '@example.com');
$buyer->setFirstName('Buyer');
$buyer->setLastName('Test');
$buyer->setPassword('hashed');
$buyer->setRoles(['ROLE_USER']);
$buyer->setIsVerified(true);
$em->persist($buyer);
$em->flush();
$client->request('GET', '/organisateur/' . $buyer->getId() . '-' . $buyer->getSlug());
self::assertResponseStatusCodeSame(404);
}
}