create(); $response = $this->actingAs($user)->getJson(route('v3.damages.index')); $response->assertForbidden(); } public function test_user_cannot_access_authentication_to_index_damage(): void { $response = $this->getJson(route('v3.damages.index')); $response->assertStatus(401); } public function test_all_damages_returned_successfully_for_index_damage(): void { $user = User::factory() ->has(factory: Permission::factory([ 'name' => 'manage-damage' ])) ->create(); Damage::factory()->count(5)->create(); $response = $this->actingAs($user)->getJson(route('v3.damages.index', [ 'start' => 0, 'size' => 10, 'filters' => json_encode([]), 'sorting' => json_encode([]), ])); $response->assertOk(); $response->assertJsonStructure([ 'data' => [ '*' => [ 'id', 'title', 'unit', 'base_price', 'status', ], ], 'meta' => [ 'totalRowCount', ], ]); } }