get_class(): Argument #1 ($object) must be of type object, null given Filament::auth()

I have a common resource for multiple users (User model, Artist Model, Affiliate Model) etc.

in the list page, in table query I have like this.. to only load logged in user specific records
public function table(Table $table): Table
    {
        return $table
            ->modifyQueryUsing(fn ($query) => $query->published()->forUserType(get_class(Filament::auth()->user()));
}

here we basicaly call where user_type = current auth user class

this works fine ..
but in test , when I do
$this->get(HelpModuleResource::getUrl('index'))->assertSuccessful();

I also add beforeEach for my pest test
beforeEach(function () {
    $this->actingAs(Artist::factory()->create(), 'artist');
    $this->actingAs(User::factory()->create(), 'web');
// other users
});

I try to do this too chain with actingAs()->startSession() but still same error


I get this error : get_class(): Argument #1 ($object) must be of type object, null given

why Filament::auth()->user() is null while user actingAs and how to fix this..
Was this page helpful?