refactor(ticket): remove service_date field and update validity time logic
This commit is contained in:
@@ -28,7 +28,6 @@ class TicketTest extends TestCase
|
||||
'source_catalog_item_id' => '20',
|
||||
'source_variant_id' => '30',
|
||||
'validity_time_id' => '40',
|
||||
'service_date' => '2026-07-21',
|
||||
'used_at' => null,
|
||||
'scanner_user_id' => '15',
|
||||
'user_id' => '10',
|
||||
@@ -39,7 +38,6 @@ class TicketTest extends TestCase
|
||||
$this->assertSame(20, $ticket->source_catalog_item_id);
|
||||
$this->assertSame(30, $ticket->source_variant_id);
|
||||
$this->assertSame(40, $ticket->validity_time_id);
|
||||
$this->assertInstanceOf(Carbon::class, $ticket->service_date);
|
||||
$this->assertNull($ticket->used_at);
|
||||
$this->assertSame(15, $ticket->scanner_user_id);
|
||||
$this->assertSame(10, $ticket->user_id);
|
||||
@@ -69,19 +67,18 @@ class TicketTest extends TestCase
|
||||
$this->assertFalse($ticket->is_expired);
|
||||
}
|
||||
|
||||
public function test_service_date_window_is_resolved_in_tenant_timezone(): void
|
||||
public function test_time_window_is_resolved_for_current_date(): void
|
||||
{
|
||||
Carbon::setTestNow('2026-07-21 14:00:00');
|
||||
$ticket = new Ticket(['service_date' => '2026-07-21']);
|
||||
Carbon::setTestNow('2026-07-21 12:00:00');
|
||||
$ticket = new Ticket;
|
||||
$ticket->setRelation('validityTime', new ValidityTime([
|
||||
'type' => ValidityTimeType::ServiceDateWindow,
|
||||
'type' => ValidityTimeType::TimeWindow,
|
||||
'start_time' => '10:00:00',
|
||||
'end_time' => '12:00:00',
|
||||
'end_time' => '14:00:00',
|
||||
]));
|
||||
$ticket->setRelation('tenant', new Tenant(['timezone' => 'America/Argentina/Buenos_Aires']));
|
||||
|
||||
$this->assertSame('2026-07-21 13:00:00', $ticket->getEffectiveStartsAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertSame('2026-07-21 15:00:00', $ticket->getEffectiveExpiresAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertSame('2026-07-21 10:00:00', $ticket->getEffectiveStartsAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertSame('2026-07-21 14:00:00', $ticket->getEffectiveExpiresAt()->format('Y-m-d H:i:s'));
|
||||
$this->assertTrue($ticket->isValid());
|
||||
}
|
||||
|
||||
@@ -114,7 +111,6 @@ class TicketTest extends TestCase
|
||||
{
|
||||
$ticket = new Ticket;
|
||||
$ticket->setRelation('validityTime', $validityTime);
|
||||
$ticket->setRelation('tenant', new Tenant(['timezone' => 'UTC']));
|
||||
|
||||
return $ticket;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user