write new tests
This commit is contained in:
47
tests/Feature/Role/IndexTest.php
Normal file
47
tests/Feature/Role/IndexTest.php
Normal 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'
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user