© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
Jo

Testing relation managers

I have followed the info at https://filamentphp.com/docs/3.x/panels/resources/relation-managers#conditionally-showing-relation-managers to conditionally show a relation manager. However, I am facing a problem where testing always passes even when the relation manager is not rendered.

As an extreme example, consider this code on the relation manager:

public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
{
    return false;
}
public static function canViewForRecord(Model $ownerRecord, string $pageClass): bool
{
    return false;
}


But this test passes:

use App\Filament\Resources\CategoryResource\Pages\EditCategory;
use function Pest\Livewire\livewire;
 
it('can render relation manager', function () {
    $category = Category::factory()
        ->has(Post::factory()->count(10))
        ->create();
 
    livewire(CategoryResource\RelationManagers\PostsRelationManager::class, [
        'ownerRecord' => $category,
        'pageClass' => EditCategory::class,
    ])
        ->assertSuccessful();
});
use App\Filament\Resources\CategoryResource\Pages\EditCategory;
use function Pest\Livewire\livewire;
 
it('can render relation manager', function () {
    $category = Category::factory()
        ->has(Post::factory()->count(10))
        ->create();
 
    livewire(CategoryResource\RelationManagers\PostsRelationManager::class, [
        'ownerRecord' => $category,
        'pageClass' => EditCategory::class,
    ])
        ->assertSuccessful();
});


In fact, to be even more extreme, I went into the
CategoryResource
CategoryResource
class and removed the
getRelations()
getRelations()
function entirely so now I definitely don't have any relation manager displaying but that test is still passing. The only way I can get the test to fail is by deleting the
PostsRelationManager
PostsRelationManager
entirely.
Managing relationships - Panel Builder - Filament
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

Testing Relation Managers
FilamentFFilament / ❓┊help
17mo ago
Relation Managers
FilamentFFilament / ❓┊help
15mo ago
Relation Managers Tab Translations
FilamentFFilament / ❓┊help
13mo ago
Counter to relation managers
FilamentFFilament / ❓┊help
17mo ago