create(); $response = $this->getJson(route('users.destroy',[$user->id])); $response->assertUnauthorized(); } public function test_user_without_permission_cannot_destroy_users(): void { $user = User::factory() ->create(); $response = $this->actingAs($user)->getJson(route('users.destroy',[$user->id])); $response->assertForbidden(); } public function test_superAdmin_cant_updated() { $user = User::factory()->create([ 'username' => "witel", ]); $response = $this->actingAs($user)->getJson(route('users.destroy',[$user->id])); $response->assertForbidden(); } public function test_can_delete_a_user() { $user = User::factory() ->has(permission::factory([ 'name'=> 'manage_users', "name_fa" => 'مدیریت کاربران', ])) ->create(); $response = $this->actingAs($user)->deleteJson(route('users.destroy', [$user->id])); $response->assertStatus(200) ->assertExactJson([ 'message' => __('messages.successful') ]); $this->assertDatabaseMissing('users', [ 'username' => $user->username ]); } }