forked from eatvio/eatvio-infra
added test permission edit show for admin and moderator
This commit is contained in:
@@ -39,16 +39,33 @@ final class EditTest extends TestCase
|
||||
|
||||
public function test_show_form_edit_recipe_success_for_author(): void
|
||||
{
|
||||
$user = $this->user;
|
||||
$recipe = Recipe::factory()->create();
|
||||
$user->author_of_recipe()->attach($recipe->id);
|
||||
$this->user->author_of_recipe()->attach($recipe->id);
|
||||
|
||||
$response = $this
|
||||
->actingAs($user)
|
||||
->actingAs($this->user)
|
||||
->get(route('recipe.edit', $recipe));
|
||||
$response->assertSuccessful();
|
||||
}
|
||||
|
||||
|
||||
public function test_show_form_edit_recipe_success_for_admin(): void
|
||||
{
|
||||
$response = $this
|
||||
->actingAs($this->user->assignRole('admin'))
|
||||
->get(route('recipe.edit', $this->recipe));
|
||||
$response->assertSuccessful();
|
||||
}
|
||||
|
||||
|
||||
public function test_show_form_edit_recipe_success_for_moderator(): void
|
||||
{
|
||||
$response = $this
|
||||
->actingAs($this->user->assignRole('moderator'))
|
||||
->get(route('recipe.edit', $this->recipe));
|
||||
$response->assertSuccessful();
|
||||
}
|
||||
|
||||
public function test_show_form_edit_recipe_forbidden_for_not_author(): void
|
||||
{
|
||||
$response = $this
|
||||
|
||||
Reference in New Issue
Block a user