Implement parent child ticket hierarchy
This commit is contained in:
@@ -125,4 +125,44 @@ class TicketTest extends TestCase
|
||||
$ticket->fresh()->fieldValues->modelKeys(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure tickets expose parent and child relationships for hierarchy rendering.
|
||||
*/
|
||||
public function test_ticket_parent_and_child_relationships_are_available(): void
|
||||
{
|
||||
$project = Project::factory()->create([
|
||||
'key' => 'CORE',
|
||||
]);
|
||||
|
||||
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||
|
||||
$priority = TicketPriority::factory()->for($project)->create([
|
||||
'name' => 'Medium',
|
||||
'position' => 1,
|
||||
]);
|
||||
|
||||
$taskType = $project->ticketTypes()->where('system_key', 'task')->firstOrFail();
|
||||
$parentType = $project->ticketTypes()->where('system_key', 'parent')->firstOrFail();
|
||||
|
||||
$parentTicket = Ticket::factory()->create([
|
||||
'project_id' => $project->id,
|
||||
'sequence_number' => 1,
|
||||
'ticket_key' => 'CORE-1',
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_type_id' => $parentType->id,
|
||||
]);
|
||||
|
||||
$childTicket = Ticket::factory()->create([
|
||||
'parent_ticket_id' => $parentTicket->id,
|
||||
'project_id' => $project->id,
|
||||
'sequence_number' => 2,
|
||||
'ticket_key' => 'CORE-2',
|
||||
'ticket_priority_id' => $priority->id,
|
||||
'ticket_type_id' => $taskType->id,
|
||||
]);
|
||||
|
||||
$this->assertSame($parentTicket->id, $childTicket->fresh()->parentTicket?->id);
|
||||
$this->assertSame([$childTicket->id], $parentTicket->fresh()->childTickets->modelKeys());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user