diff --git a/tests/Controller/AccountControllerTest.php b/tests/Controller/AccountControllerTest.php index a094a79..610e4b8 100644 --- a/tests/Controller/AccountControllerTest.php +++ b/tests/Controller/AccountControllerTest.php @@ -2750,6 +2750,56 @@ class AccountControllerTest extends WebTestCase self::assertResponseRedirects('/mon-compte/evenement/'.$event->getId().'/modifier?tab=attestation'); } + public function testEventAttestationWithSoldTickets(): void + { + $client = static::createClient(); + $em = static::getContainer()->get(EntityManagerInterface::class); + $user = $this->createUser(['ROLE_ORGANIZER'], true); + $user->setCompanyName('Test Asso'); + $user->setSiret('12345678901234'); + $em->flush(); + + $event = $this->createEvent($em, $user); + $category = $this->createCategory($em, $event); + $billet = $this->createBillet($em, $category); + + $order = new \App\Entity\BilletBuyer(); + $order->setEvent($event); + $order->setFirstName('Jean'); + $order->setLastName('Dupont'); + $order->setEmail('jean-att@test.fr'); + $order->setOrderNumber('T-'.substr(uniqid(), -7)); + $order->setTotalHT(1000); + $order->setStatus(\App\Entity\BilletBuyer::STATUS_PAID); + $order->setPaidAt(new \DateTimeImmutable()); + + $item = new \App\Entity\BilletBuyerItem(); + $item->setBillet($billet); + $item->setBilletName('Test'); + $item->setQuantity(2); + $item->setUnitPriceHT(500); + $order->addItem($item); + $em->persist($order); + $em->flush(); + + $ticket = new \App\Entity\BilletOrder(); + $ticket->setBilletBuyer($order); + $ticket->setBillet($billet); + $ticket->setBilletName('Test'); + $ticket->setUnitPriceHT(500); + $em->persist($ticket); + $em->flush(); + + $client->loginUser($user); + $client->request('POST', '/mon-compte/evenement/'.$event->getId().'/attestation', [ + 'categories' => [$category->getId()], + 'mode' => 'detail', + ]); + + self::assertResponseIsSuccessful(); + self::assertStringContainsString('application/pdf', $client->getResponse()->headers->get('Content-Type')); + } + /** * @param list $roles */