write new tests

This commit is contained in:
2025-05-12 17:05:42 +03:30
parent 70f3c36f58
commit db8cda55df
13 changed files with 507 additions and 18 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace Tests\Feature\Role;
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_the_user_is_not_authenticated(): void
{
$response = $this->getJson(route('roles.index'));
$response->assertStatus(401);
}
public function test_authenticated_user_can_see_roles_index(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->getJson(route('roles.index',[
'filters' => json_encode([]),
'sorting' => json_encode([]),
]));
$response->assertOk();
$response->assertJsonStructure([
'data' => [
'*' => [
'id',
'name',
'name_fa',
],
],
'meta' => [
'totalRowCount'
]
]);
}
}