Files
e-ticket/tests/EventSubscriber/DisableProfilerSubscriberTest.php
Serreau Jovann 179a0703f8 Add Billet entity, BilletDesign, ticket designer, CRUD billets, commissions
- Create Billet entity: name, position, priceHT, quantity (nullable=unlimited),
  isGeneratedBillet, hasDefinedExit, notBuyable, type (billet/reservation_brocante/vote),
  stripeProductId, description, picture (VichUploader), category (ManyToOne CASCADE)
- Create BilletDesign entity (OneToOne Event): accentColor, invitationTitle, invitationColor
- Billet CRUD: add/edit/delete with access control, Stripe product sync on connected account
- Billet reorder: drag & drop with position field, refactored sortable.js for both categories and billets
- Ticket designer tab (custom offer only): accent color, invitation title/color, live iframe preview
- A4 ticket preview: 4 zones (HG infos+billet, HD affiche, BG association, BD sortie+invitation), fake QR code SVG
- Commission calculator JS: live breakdown of E-Ticket fee, Stripe fee (1.5%+0.25EUR), net amount
- Sales recap on categories tab: qty sold, total HT, total commissions, total net
- DisableProfilerSubscriber: disable web profiler toolbar on preview iframe
- CSP: allow self in frame-src and frame-ancestors for preview iframe
- Flysystem: dedicated billets.storage for billet images
- Upload accept restricted to png/jpeg/webp/gif (no HEIC)
- Makefile: add force_sql_dev command
- CLAUDE.md: add rule to never modify existing migrations
- Consolidate all migrations into single Version20260321111125
- Tests: BilletTest (20), BilletDesignTest (6), DisableProfilerSubscriberTest (5),
  billet-designer.test.js (7), commission-calculator.test.js (7),
  AccountControllerTest billet CRUD tests (11)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-21 12:19:46 +01:00

86 lines
2.9 KiB
PHP

<?php
namespace App\Tests\EventSubscriber;
use App\EventSubscriber\DisableProfilerSubscriber;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Profiler\Profiler;
class DisableProfilerSubscriberTest extends TestCase
{
public function testSubscribedEvents(): void
{
$events = DisableProfilerSubscriber::getSubscribedEvents();
self::assertArrayHasKey(KernelEvents::RESPONSE, $events);
}
public function testDisablesProfilerOnBilletPreviewRoute(): void
{
$profiler = $this->createMock(Profiler::class);
$profiler->expects(self::once())->method('disable');
$subscriber = new DisableProfilerSubscriber($profiler);
$request = new Request();
$request->attributes->set('_route', 'app_account_event_billet_preview');
$kernel = $this->createMock(HttpKernelInterface::class);
$event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, new Response());
$subscriber->onKernelResponse($event);
}
public function testDoesNotDisableProfilerOnOtherRoutes(): void
{
$profiler = $this->createMock(Profiler::class);
$profiler->expects(self::never())->method('disable');
$subscriber = new DisableProfilerSubscriber($profiler);
$request = new Request();
$request->attributes->set('_route', 'app_home');
$kernel = $this->createMock(HttpKernelInterface::class);
$event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, new Response());
$subscriber->onKernelResponse($event);
}
public function testHandlesNullProfiler(): void
{
$subscriber = new DisableProfilerSubscriber(null);
$request = new Request();
$request->attributes->set('_route', 'app_account_event_billet_preview');
$kernel = $this->createMock(HttpKernelInterface::class);
$event = new ResponseEvent($kernel, $request, HttpKernelInterface::MAIN_REQUEST, new Response());
// No exception thrown
$subscriber->onKernelResponse($event);
self::assertTrue(true);
}
public function testIgnoresSubRequests(): void
{
$profiler = $this->createMock(Profiler::class);
$profiler->expects(self::never())->method('disable');
$subscriber = new DisableProfilerSubscriber($profiler);
$request = new Request();
$request->attributes->set('_route', 'app_account_event_billet_preview');
$kernel = $this->createMock(HttpKernelInterface::class);
$event = new ResponseEvent($kernel, $request, HttpKernelInterface::SUB_REQUEST, new Response());
$subscriber->onKernelResponse($event);
}
}