Add missing AccountController coverage: billetPreview, saveBilletDesign, reorderBillets, deleteBillet 404
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1280,6 +1280,167 @@ class AccountControllerTest extends WebTestCase
|
||||
self::assertResponseStatusCodeSame(403);
|
||||
}
|
||||
|
||||
public function testDeleteBilletNotFound(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$em = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$user = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
|
||||
$event = $this->createEvent($em, $user);
|
||||
|
||||
$client->loginUser($user);
|
||||
$client->request('POST', '/mon-compte/evenement/'.$event->getId().'/billet/999999/supprimer');
|
||||
|
||||
self::assertResponseStatusCodeSame(404);
|
||||
}
|
||||
|
||||
public function testBilletPreview(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$em = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$user = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
|
||||
$event = $this->createEvent($em, $user);
|
||||
|
||||
$client->loginUser($user);
|
||||
$client->request('GET', '/mon-compte/evenement/'.$event->getId().'/billet-preview');
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function testBilletPreviewDeniedForOtherUser(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$em = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$owner = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
$other = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
|
||||
$event = $this->createEvent($em, $owner);
|
||||
|
||||
$client->loginUser($other);
|
||||
$client->request('GET', '/mon-compte/evenement/'.$event->getId().'/billet-preview');
|
||||
|
||||
self::assertResponseStatusCodeSame(403);
|
||||
}
|
||||
|
||||
public function testSaveBilletDesign(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$em = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$user = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
|
||||
$event = $this->createEvent($em, $user);
|
||||
|
||||
$client->loginUser($user);
|
||||
$client->request('POST', '/mon-compte/evenement/'.$event->getId().'/billet-design', [
|
||||
'accent_color' => '#ff0000',
|
||||
'invitation_title' => 'VIP',
|
||||
'invitation_color' => '#00ff00',
|
||||
]);
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
|
||||
$design = $em->getRepository(\App\Entity\BilletDesign::class)->findOneBy(['event' => $event]);
|
||||
self::assertNotNull($design);
|
||||
self::assertSame('#ff0000', $design->getAccentColor());
|
||||
self::assertSame('VIP', $design->getInvitationTitle());
|
||||
}
|
||||
|
||||
public function testSaveBilletDesignUpdatesExisting(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$em = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$user = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
|
||||
$event = $this->createEvent($em, $user);
|
||||
|
||||
$design = new \App\Entity\BilletDesign();
|
||||
$design->setEvent($event);
|
||||
$em->persist($design);
|
||||
$em->flush();
|
||||
|
||||
$client->loginUser($user);
|
||||
$client->request('POST', '/mon-compte/evenement/'.$event->getId().'/billet-design', [
|
||||
'accent_color' => '#aabbcc',
|
||||
'invitation_title' => 'Pass',
|
||||
'invitation_color' => '#112233',
|
||||
]);
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
|
||||
$em->refresh($design);
|
||||
self::assertSame('#aabbcc', $design->getAccentColor());
|
||||
self::assertSame('Pass', $design->getInvitationTitle());
|
||||
}
|
||||
|
||||
public function testSaveBilletDesignDeniedForOtherUser(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$em = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$owner = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
$other = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
|
||||
$event = $this->createEvent($em, $owner);
|
||||
|
||||
$client->loginUser($other);
|
||||
$client->request('POST', '/mon-compte/evenement/'.$event->getId().'/billet-design', [
|
||||
'accent_color' => '#ff0000',
|
||||
]);
|
||||
|
||||
self::assertResponseStatusCodeSame(403);
|
||||
}
|
||||
|
||||
public function testReorderBillets(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$em = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$user = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
|
||||
$event = $this->createEvent($em, $user);
|
||||
$category = $this->createCategory($em, $event);
|
||||
$b1 = $this->createBillet($em, $category, 'B1', 1000);
|
||||
$b2 = $this->createBillet($em, $category, 'B2', 2000);
|
||||
|
||||
$client->loginUser($user);
|
||||
$client->request(
|
||||
'POST',
|
||||
'/mon-compte/evenement/'.$event->getId().'/billet/reorder',
|
||||
[],
|
||||
[],
|
||||
['CONTENT_TYPE' => 'application/json'],
|
||||
json_encode([$b2->getId(), $b1->getId()])
|
||||
);
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
|
||||
$em->refresh($b1);
|
||||
$em->refresh($b2);
|
||||
self::assertSame(1, $b1->getPosition());
|
||||
self::assertSame(0, $b2->getPosition());
|
||||
}
|
||||
|
||||
public function testReorderBilletsDeniedForOtherUser(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$em = static::getContainer()->get(EntityManagerInterface::class);
|
||||
$owner = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
$other = $this->createUser(['ROLE_ORGANIZER'], true);
|
||||
|
||||
$event = $this->createEvent($em, $owner);
|
||||
|
||||
$client->loginUser($other);
|
||||
$client->request(
|
||||
'POST',
|
||||
'/mon-compte/evenement/'.$event->getId().'/billet/reorder',
|
||||
[],
|
||||
[],
|
||||
['CONTENT_TYPE' => 'application/json'],
|
||||
'[]'
|
||||
);
|
||||
|
||||
self::assertResponseStatusCodeSame(403);
|
||||
}
|
||||
|
||||
private function createBillet(EntityManagerInterface $em, \App\Entity\Category $category, string $name = 'Test Billet', int $priceHT = 1000): \App\Entity\Billet
|
||||
{
|
||||
$billet = new \App\Entity\Billet();
|
||||
|
||||
Reference in New Issue
Block a user