forked from eatvio/eatvio-infra
added test permission edit show for admin and moderator
This commit is contained in:
@@ -34,23 +34,44 @@ class EditTest extends TestCase
|
||||
|
||||
public function test_show_form_edit_plan_success_for_author(): void
|
||||
{
|
||||
$plan = $this->plan;
|
||||
$plan->author()->attach($this->user->id);
|
||||
$this->plan->author()->attach($this->user->id);
|
||||
|
||||
$response = $this
|
||||
->actingAs($this->user)
|
||||
->get(route('plan.edit', $plan));
|
||||
->get(route('plan.edit', $this->plan));
|
||||
$response->assertSuccessful();
|
||||
}
|
||||
|
||||
public function test_show_form_edit_plan_fail_for_not_author(): void
|
||||
|
||||
public function test_show_form_edit_plan_success_for_admin(): void
|
||||
{
|
||||
$this->plan->author()->attach($this->user->id);
|
||||
|
||||
$response = $this
|
||||
->actingAs($this->user->assignRole('admin'))
|
||||
->get(route('plan.edit', $this->plan));
|
||||
$response->assertSuccessful();
|
||||
}
|
||||
|
||||
|
||||
public function test_show_form_edit_plan_success_for_moderator(): void
|
||||
{
|
||||
$this->plan->author()->attach($this->user->id);
|
||||
|
||||
$response = $this
|
||||
->actingAs($this->user->assignRole('moderator'))
|
||||
->get(route('plan.edit', $this->plan));
|
||||
$response->assertSuccessful();
|
||||
}
|
||||
|
||||
public function test_show_form_edit_plan_forbidden_for_not_author(): void
|
||||
{
|
||||
$plan = $this->plan;
|
||||
$user = User::factory()->create();
|
||||
$plan->author()->attach($user->id);
|
||||
$this->plan->author()->attach($user->id);
|
||||
|
||||
$response = $this
|
||||
->actingAs($this->user)
|
||||
->get(route('plan.edit', $plan));
|
||||
->get(route('plan.edit', $this->plan));
|
||||
|
||||
$response->assertForbidden();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user