44 lines
1.0 KiB
PHP
44 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\V3\Damage;
|
|
|
|
use App\Models\Damage;
|
|
use App\Models\User;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
use Spatie\Permission\Models\Permission;
|
|
use Tests\TestCase;
|
|
|
|
class ListTest extends TestCase
|
|
{
|
|
use RefreshDatabase, WithFaker;
|
|
|
|
public function test_user_cannot_access_authentication(): void
|
|
{
|
|
|
|
$response = $this->getJson(route('v3.damages.list'));
|
|
$response->assertStatus(401);
|
|
}
|
|
public function test_all_damages_returned_successfully_for_list(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
Damage::factory()->count(5)->create();
|
|
$response = $this->actingAs($user)->getJson(route('v3.damages.list'));
|
|
$response->assertOk();
|
|
$response->assertJsonStructure([
|
|
'data' => [
|
|
'*' => [
|
|
'id',
|
|
'title',
|
|
'unit',
|
|
'base_price',
|
|
'status',
|
|
],
|
|
],
|
|
]);
|
|
|
|
}
|
|
}
|
|
|
|
|