Add attestation test with sold tickets to cover buildAttestationStats and buildAttestationTicketDetails
Creates a paid order with BilletOrder tickets before generating the attestation, exercising the soldCounts loop (line 503) and ticket details loop (lines 546-551) in AccountEventOperationsController. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -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<string> $roles
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user