feat(ticket): implement terminal status management and validation
This commit is contained in:
@@ -13,6 +13,7 @@ use App\Domains\Ticket\Services\ResolvedTicketValidity;
|
||||
use App\Domains\Ticket\Services\ResolvedValidityGroup;
|
||||
use App\Domains\Ticket\Services\TicketValidityResolver;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TicketTest extends TestCase
|
||||
@@ -202,6 +203,36 @@ class TicketTest extends TestCase
|
||||
$this->assertSame(Ticket::STATUS_REFUNDED, $ticket->status);
|
||||
}
|
||||
|
||||
public function test_it_marks_tickets_with_terminal_statuses(): void
|
||||
{
|
||||
Carbon::setTestNow('2026-09-10 12:00:00');
|
||||
|
||||
$disabled = new Ticket;
|
||||
$disabled->markAsDisabled();
|
||||
|
||||
$cancelled = new Ticket;
|
||||
$cancelled->markAsCancelled();
|
||||
|
||||
$refunded = new Ticket;
|
||||
$refunded->markAsRefunded();
|
||||
|
||||
$this->assertSame(Ticket::STATUS_DISABLED, $disabled->status);
|
||||
$this->assertSame('2026-09-10 12:00:00', $disabled->disabled_at->format('Y-m-d H:i:s'));
|
||||
$this->assertSame(Ticket::STATUS_CANCELLED, $cancelled->status);
|
||||
$this->assertSame('2026-09-10 12:00:00', $cancelled->cancelled_at->format('Y-m-d H:i:s'));
|
||||
$this->assertSame(Ticket::STATUS_REFUNDED, $refunded->status);
|
||||
$this->assertSame('2026-09-10 12:00:00', $refunded->refunded_at->format('Y-m-d H:i:s'));
|
||||
}
|
||||
|
||||
public function test_it_does_not_allow_a_transition_between_terminal_statuses(): void
|
||||
{
|
||||
$ticket = new Ticket;
|
||||
$ticket->markAsDisabled();
|
||||
|
||||
$this->expectException(ValidationException::class);
|
||||
$ticket->markAsRefunded();
|
||||
}
|
||||
|
||||
public function test_all_validity_times_in_the_same_group_must_be_active(): void
|
||||
{
|
||||
Carbon::setTestNow('2026-08-20 13:00:00');
|
||||
|
||||
Reference in New Issue
Block a user