© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•5mo ago•
3 replies
Patabugen

How to test permissions for the Delete action?

I've got tests which check my policies are setup correct - they basically create a user with a role, and check the HTTP response from accessing that page (view/edit etc) through filament.

I'm not sure how to test the Delete permissions, because it's only an action - can anyone offer any suggestions?

Here's an example of my Edit User test: (any feedback/suggestions on the tests also welcome :))

    #[TestWith(['admin', 200], 'admin')]
    #[TestWith(['api', 403], 'api')]
    public function test_permission_to_edit_user(string $role, int $expectedStatus)
    {
        $this->actingAs($this->createUserWithRole($role));

        $user = User::factory()->admin()->create();

        $response = $this->get(Filament::getResourceUrl(
            User::class,
            'edit',
            ['record' => $user->id]
        ));
        $response->assertStatus($expectedStatus);
    }
    #[TestWith(['admin', 200], 'admin')]
    #[TestWith(['api', 403], 'api')]
    public function test_permission_to_edit_user(string $role, int $expectedStatus)
    {
        $this->actingAs($this->createUserWithRole($role));

        $user = User::factory()->admin()->create();

        $response = $this->get(Filament::getResourceUrl(
            User::class,
            'edit',
            ['record' => $user->id]
        ));
        $response->assertStatus($expectedStatus);
    }
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to test Infolist Action?
FilamentFFilament / ❓┊help
2y ago
How to listen for repeater delete item action
FilamentFFilament / ❓┊help
5mo ago
How to test an action in the getFormAction
FilamentFFilament / ❓┊help
6mo ago
How to edit delete bulk action
FilamentFFilament / ❓┊help
2y ago