phases one of time logged
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Modules\Helpdesk\Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Modules\Helpdesk\Models\Ticket;
|
||||
use Tests\TestCase;
|
||||
|
||||
final class TicketTimeLogTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* It stores a time log for an authorized ticket user.
|
||||
*/
|
||||
public function test_authorized_user_can_log_ticket_time(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$ticket = Ticket::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->post(route('helpdesk.tickets.time-logs.store', $ticket), [
|
||||
'minutes' => 45,
|
||||
'description' => 'Investigated the issue and updated the ticket.',
|
||||
])
|
||||
->assertRedirect();
|
||||
|
||||
$this->assertDatabaseHas('helpdesk_time_logs', [
|
||||
'ticket_id' => $ticket->id,
|
||||
'user_id' => $user->id,
|
||||
'minutes' => 45,
|
||||
'description' => 'Investigated the issue and updated the ticket.',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* It rejects invalid logged minutes.
|
||||
*/
|
||||
public function test_ticket_time_log_requires_valid_minutes(): void
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
$ticket = Ticket::factory()->create();
|
||||
|
||||
$this->actingAs($user)
|
||||
->from(route('helpdesk.tickets.show', $ticket))
|
||||
->post(route('helpdesk.tickets.time-logs.store', $ticket), [
|
||||
'minutes' => 0,
|
||||
])
|
||||
->assertRedirect(route('helpdesk.tickets.show', $ticket))
|
||||
->assertSessionHasErrors('minutes');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user