feat: add support for multiple event dates in variants
- Updated the FeaturedGroupService to include 'variants.eventDates' in the items query. - Introduced a BelongsToMany relationship in EventDate for selected variants. - Modified PurchaseItemResource and PurchaseItemSnapshotFactory to handle multiple event dates for variants. - Enhanced StartCheckoutService to load event dates for variants. - Updated TicketGeneratorService to accommodate event dates in ticket generation. - Created migrations to support multi-value event dates and allow multiple variant values per attribute. - Adjusted seeders to reflect new event date handling and added new attributes. - Added tests to ensure correct functionality for multi-date variants and their integration with ticket generation.
This commit is contained in:
@@ -235,6 +235,31 @@ class TicketGeneratorServiceTest extends TestCase
|
||||
$this->assertSame('2026-08-21 02:00:00', $fixedWindow->fixed_expires_at->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
public function test_a_multi_date_variant_generates_one_ticket_for_each_selected_date(): void
|
||||
{
|
||||
$item = $this->createTicketableItem('multi-date-pass');
|
||||
$dates = collect(['2026-08-20', '2026-08-21'])->map(fn (string $date) => EventDate::query()->create([
|
||||
'tenant_code' => $this->tenant->codigo,
|
||||
'date' => $date,
|
||||
'time_start' => '00:00:00',
|
||||
'time_end' => '23:59:59',
|
||||
]));
|
||||
$variant = $item->variants()->create([
|
||||
'inventory_id' => Inventory::query()->create()->id,
|
||||
]);
|
||||
$variant->eventDates()->sync($dates->pluck('id'));
|
||||
|
||||
$tickets = $this->service->generate($item, $this->user, 1, $variant->id);
|
||||
$tickets->each->loadMissing('validityTime');
|
||||
|
||||
$this->assertCount(2, $tickets);
|
||||
$this->assertSame(
|
||||
['2026-08-20 00:00:00', '2026-08-21 00:00:00'],
|
||||
$tickets->map(fn ($ticket): string => $ticket->validityTime->fixed_starts_at->format('Y-m-d H:i:s'))->all(),
|
||||
);
|
||||
$this->assertSame([$variant->id], $tickets->pluck('source_variant_id')->unique()->values()->all());
|
||||
}
|
||||
|
||||
public function test_marking_a_purchase_as_paid_ignores_items_without_tickets(): void
|
||||
{
|
||||
Event::fake([TicketsAvailable::class]);
|
||||
|
||||
Reference in New Issue
Block a user