seedLookupData(); $owner = $this->user(['name' => 'Ticket Owner']); $agent = $this->agent(['name' => 'Assigned Agent']); $ticket = $this->ticket([ 'owner' => $owner, 'agent' => $agent, 'status_id' => $fixtures['open']->id, 'priority_id' => $fixtures['normal']->id, ]); $this->actingAs($agent) ->post(route('helpdesk.tickets.time-logs.store', $ticket), [ 'minutes' => 45, 'description' => 'Investigated the issue and updated the ticket.', ]) ->assertRedirect(route('helpdesk.tickets.show', $ticket)); $this->assertDatabaseHas('helpdesk_time_logs', [ 'ticket_id' => $ticket->id, 'user_id' => $agent->id, 'minutes' => 45, 'description' => 'Investigated the issue and updated the ticket.', ]); } /** * It rejects invalid logged minutes for an authorized ticket agent. */ public function test_ticket_time_log_requires_valid_minutes(): void { $fixtures = $this->seedLookupData(); $owner = $this->user(['name' => 'Ticket Owner']); $agent = $this->agent(['name' => 'Assigned Agent']); $ticket = $this->ticket([ 'owner' => $owner, 'agent' => $agent, 'status_id' => $fixtures['open']->id, 'priority_id' => $fixtures['normal']->id, ]); $this->actingAs($agent) ->from(route('helpdesk.tickets.show', $ticket)) ->post(route('helpdesk.tickets.time-logs.store', $ticket), [ 'minutes' => 0, ]) ->assertRedirect(route('helpdesk.tickets.show', $ticket)) ->assertSessionHasErrors('minutes'); } }