Files
backend/tests/Feature/Permission/IndexTest.php

46 lines
1.0 KiB
PHP

<?php
namespace Tests\Feature\Permission;
use App\Models\Permission;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class IndexTest extends TestCase
{
use RefreshDatabase, WithFaker;
public function test_unauthenticated_user_cannot_access(): void
{
$response = $this->getJson(route('permissions.index'));
$response->assertUnauthorized();
}
public function test_all_permissions_returned_successfully(): void
{
$user = User::factory()
->create();
$response = $this->actingAs($user)->getJson(route('permissions.index'));
$response->assertOk();
$response->assertJsonStructure([
'data' => [
'*' => [
'id',
'name',
'name_fa',
'guard_name',
'created_at',
'updated_at',
],
]
]);
}
}