- Create BilletBuyer entity: event, user (nullable for guests), firstName,
lastName, email, reference (ETICKET-XXXX-XXXX-XXXX), totalHT, status,
stripeSessionId, paidAt, items (OneToMany)
- Create BilletBuyerItem entity: billet, billetName (snapshot), quantity,
unitPriceHT, line total helpers
- OrderController with full checkout flow:
- POST /evenement/{id}/commander: create order from cart JSON
- GET/POST /commande/{id}/informations: guest form (name, email)
- GET /commande/{id}/paiement: payment page with recap
- POST /commande/{id}/stripe: Stripe Checkout on connected account
with application_fee, productId, and quantities
- GET /commande/{id}/confirmation: success page
- Cart JS: POST cart data on Commander click, redirect to guest/payment
- Templates: guest form, payment page, order summary partial, success page
- Stripe payment uses organizer connected account, application_fee based
on commissionRate, existing productId when available
- Tests: BilletBuyerTest (12), BilletBuyerItemTest (6), cart.test.js (13)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
85 lines
2.4 KiB
PHP
85 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Entity;
|
|
|
|
use App\Entity\Billet;
|
|
use App\Entity\BilletBuyer;
|
|
use App\Entity\BilletBuyerItem;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class BilletBuyerItemTest extends TestCase
|
|
{
|
|
public function testDefaults(): void
|
|
{
|
|
$item = new BilletBuyerItem();
|
|
|
|
self::assertNull($item->getId());
|
|
self::assertNull($item->getBilletBuyer());
|
|
self::assertNull($item->getBillet());
|
|
self::assertNull($item->getBilletName());
|
|
self::assertSame(1, $item->getQuantity());
|
|
self::assertSame(0, $item->getUnitPriceHT());
|
|
self::assertSame(0.0, $item->getUnitPriceHTDecimal());
|
|
self::assertSame(0, $item->getLineTotalHT());
|
|
self::assertSame(0.0, $item->getLineTotalHTDecimal());
|
|
}
|
|
|
|
public function testSetAndGetBilletBuyer(): void
|
|
{
|
|
$item = new BilletBuyerItem();
|
|
$buyer = new BilletBuyer();
|
|
$result = $item->setBilletBuyer($buyer);
|
|
|
|
self::assertSame($buyer, $item->getBilletBuyer());
|
|
self::assertSame($item, $result);
|
|
}
|
|
|
|
public function testSetAndGetBillet(): void
|
|
{
|
|
$item = new BilletBuyerItem();
|
|
$billet = new Billet();
|
|
$result = $item->setBillet($billet);
|
|
|
|
self::assertSame($billet, $item->getBillet());
|
|
self::assertSame($item, $result);
|
|
}
|
|
|
|
public function testSetAndGetQuantity(): void
|
|
{
|
|
$item = new BilletBuyerItem();
|
|
$result = $item->setQuantity(3);
|
|
|
|
self::assertSame(3, $item->getQuantity());
|
|
self::assertSame($item, $result);
|
|
}
|
|
|
|
public function testSetAndGetUnitPriceHT(): void
|
|
{
|
|
$item = new BilletBuyerItem();
|
|
$result = $item->setUnitPriceHT(1500);
|
|
|
|
self::assertSame(1500, $item->getUnitPriceHT());
|
|
self::assertSame(15.0, $item->getUnitPriceHTDecimal());
|
|
self::assertSame($item, $result);
|
|
}
|
|
|
|
public function testSetAndGetBilletName(): void
|
|
{
|
|
$item = new BilletBuyerItem();
|
|
$result = $item->setBilletName('Entree VIP');
|
|
|
|
self::assertSame('Entree VIP', $item->getBilletName());
|
|
self::assertSame($item, $result);
|
|
}
|
|
|
|
public function testLineTotalHT(): void
|
|
{
|
|
$item = new BilletBuyerItem();
|
|
$item->setUnitPriceHT(1500);
|
|
$item->setQuantity(3);
|
|
|
|
self::assertSame(4500, $item->getLineTotalHT());
|
|
self::assertSame(45.0, $item->getLineTotalHTDecimal());
|
|
}
|
|
}
|