42 lines
1.0 KiB
PHP
42 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 DeleteTest extends TestCase
|
|
{
|
|
use RefreshDatabase, WithFaker;
|
|
|
|
public function test_authenticated_user_can_delete_permission(): void
|
|
{
|
|
$user = User::factory()->create();
|
|
$permission = Permission::factory()->create();
|
|
|
|
$response = $this->actingAs($user)->deleteJson(route('permissions.destroy', $permission));
|
|
|
|
$response->assertOk()
|
|
->assertJson([
|
|
'message' => __('messages.successful'),
|
|
]);
|
|
|
|
$this->assertDatabaseMissing('permissions', [
|
|
'id' => $permission->id,
|
|
]);
|
|
}
|
|
|
|
public function test_guest_cannot_delete_permission(): void
|
|
{
|
|
$permission = Permission::factory()->create();
|
|
|
|
$response = $this->deleteJson(route('permissions.destroy', $permission));
|
|
|
|
$response->assertUnauthorized();
|
|
}
|
|
|
|
}
|