feat(ticket): add entry reservation handling to ticket refund logic and tests

This commit is contained in:
2026-09-25 11:20:12 -03:00
parent 57d278336d
commit f29c5692b9
4 changed files with 88 additions and 2 deletions

View File

@@ -2,10 +2,11 @@
namespace Tests\Unit\Ticket;
use App\Domains\Core\Auth\Models\User;
use App\Domains\Commerce\Catalog\Models\CatalogItem;
use App\Domains\Commerce\Catalog\Models\Variant;
use App\Domains\Core\Auth\Models\User;
use App\Domains\Core\Tenant\Models\Tenant;
use App\Domains\Ticketing\Desfile\Models\EntryReservation;
use App\Domains\Ticketing\Ticket\Enums\ValidityTimeType;
use App\Domains\Ticketing\Ticket\Models\Ticket;
use App\Domains\Ticketing\Ticket\Models\ValidityTime;
@@ -54,6 +55,7 @@ class TicketTest extends TestCase
$this->assertInstanceOf(User::class, $ticket->scannerUser()->getRelated());
$this->assertInstanceOf(CatalogItem::class, $ticket->sourceCatalogItem()->getRelated());
$this->assertInstanceOf(Variant::class, $ticket->sourceVariant()->getRelated());
$this->assertInstanceOf(EntryReservation::class, $ticket->entryReservation()->getRelated());
}
public function test_unused_ticket_without_validity_time_is_valid(): void
@@ -83,6 +85,21 @@ class TicketTest extends TestCase
$this->assertFalse($active->can_refund());
}
public function test_a_ticket_with_an_entry_reservation_cannot_be_refunded(): void
{
$tenant = new Tenant([
'allow_ticket_refund' => true,
'allow_ticket_total_refund' => true,
]);
$ticket = (new Ticket)
->setRelation('tenant', $tenant)
->setRelation('entryReservation', new EntryReservation);
$this->assertTrue($ticket->is_active());
$this->assertTrue($ticket->allow_refund());
$this->assertFalse($ticket->can_refund());
}
public function test_fixed_window_controls_ticket_validity(): void
{
Carbon::setTestNow('2026-07-21 10:00:00');