F
Filament3mo ago
Aminne

Writing unit testing using shield plugin filament for role and permissions

How i can create a unit test for application has a filament plugin shield ?
Solution:
I think actingAs supports guard in the second param..
Jump to solution
7 Replies
LeandroFerreira
LeandroFerreira3mo ago
what part would you like to test?
Aminne
AminneOP3mo ago
I have seen your discution , i find the solution, but i have another problem, my default guard is 'api' how i can update the guard 'web' for testing filament, and guard'api' for testing the 'api/' ? how i can switch between them ?
Aminne
AminneOP3mo ago
Disable shields for testing - Filament
Hey, I'm using the filament-shield package. How do you disable all the shields for testing? In my testcase I do
protected function setUp(): void
{
parent::setUp();

$this->actingAs(User::factory()->create());
}
protected function setUp(): void
{
parent::setUp();

$this->actingAs(User::factory()->create());
}
But I still get a 403. I guess it's because of shields
Solution
LeandroFerreira
LeandroFerreira3mo ago
I think actingAs supports guard in the second param..
Aminne
AminneOP3mo ago
aah good, thi's my solution, thank you. It works,
beforeEach(function () {
$this->actingAs(loginFilament(), 'web');
});
beforeEach(function () {
$this->actingAs(loginFilament(), 'web');
});
Aminne
AminneOP3mo ago
Yes, i'm reading it.
Want results from more Discord servers?
Add your server