- Introduced Event and EventDate models with relationships to Tenant and CatalogItem. - Added active_event_id to Tenant model to track the currently active event. - Updated TenantResource to include active event details in the response. - Enhanced Ticket model to link to CatalogItem and Variant, allowing for event-specific ticketing. - Implemented migrations to create events and link them to catalog items and variants. - Updated seeders to populate events and their associated dates for the Fiesta Futbol Infantil tenant. - Modified Ticket generation logic to respect event dates over standard ticket dates. - Added tests for event and ticket functionalities, ensuring proper relationships and date handling.
50 lines
1.8 KiB
PHP
50 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Event;
|
|
|
|
use App\Domains\Catalog\Models\CatalogItem;
|
|
use App\Domains\Catalog\Models\Variant;
|
|
use App\Domains\Event\Models\Event;
|
|
use App\Domains\Event\Models\EventDate;
|
|
use App\Domains\Tenant\Models\Tenant;
|
|
use Tests\TestCase;
|
|
|
|
class EventModelsTest extends TestCase
|
|
{
|
|
public function test_event_maps_its_tenant_dates_and_catalog_items(): void
|
|
{
|
|
$event = new Event;
|
|
|
|
$this->assertFalse($event->usesTimestamps());
|
|
$this->assertInstanceOf(Tenant::class, $event->tenant()->getRelated());
|
|
$this->assertInstanceOf(EventDate::class, $event->dates()->getRelated());
|
|
$this->assertInstanceOf(CatalogItem::class, $event->catalogItems()->getRelated());
|
|
}
|
|
|
|
public function test_event_date_maps_schedule_and_variants(): void
|
|
{
|
|
$eventDate = new EventDate;
|
|
$eventDate->setRawAttributes([
|
|
'event_id' => '10',
|
|
'date' => '2026-10-09',
|
|
'time_start' => '09:00:00',
|
|
'time_end' => '18:30:00',
|
|
]);
|
|
|
|
$this->assertFalse($eventDate->usesTimestamps());
|
|
$this->assertSame(10, $eventDate->event_id);
|
|
$this->assertSame('2026-10-09 09:00:00', $eventDate->startsAt()->format('Y-m-d H:i:s'));
|
|
$this->assertSame('2026-10-09 18:30:00', $eventDate->endsAt()->format('Y-m-d H:i:s'));
|
|
$this->assertInstanceOf(Event::class, $eventDate->event()->getRelated());
|
|
$this->assertInstanceOf(Variant::class, $eventDate->variants()->getRelated());
|
|
}
|
|
|
|
public function test_tenant_has_many_events_and_one_active_event(): void
|
|
{
|
|
$tenant = new Tenant;
|
|
|
|
$this->assertInstanceOf(Event::class, $tenant->events()->getRelated());
|
|
$this->assertInstanceOf(Event::class, $tenant->activeEvent()->getRelated());
|
|
}
|
|
}
|