70 lines
2.2 KiB
PHP
Executable File
70 lines
2.2 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Modules\Helpdesk\Tests\Feature;
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Modules\Helpdesk\Tests\Concerns\BuildsHelpdeskFixtures;
|
|
use Tests\TestCase;
|
|
|
|
final class TicketTimeLogTest extends TestCase
|
|
{
|
|
use BuildsHelpdeskFixtures;
|
|
use RefreshDatabase;
|
|
|
|
/**
|
|
* It stores a time log for an authorized ticket agent.
|
|
*/
|
|
public function test_authorized_user_can_log_ticket_time(): 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)
|
|
->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');
|
|
}
|
|
}
|