add staff remove & staff invite test

This commit is contained in:
2020-08-15 12:13:09 +02:00
parent 0b9229d966
commit 92d83d9f9a
7 changed files with 111 additions and 11 deletions

View File

@@ -346,7 +346,7 @@ class EventsTest extends TestCase
}
/** @test */
public function only_the_owner_can_patch_the_event()
public function only_the_owner_or_staff_can_patch_the_event()
{
$user = factory(User::class)->create();
$event = factory(Event::class)->create(['id' => 123, 'user_id' => $user->id]);
@@ -394,7 +394,7 @@ class EventsTest extends TestCase
$event = factory(Event::class)->create(['user_id' => $user->id]);
$userTwo = factory(User::class)->create();
$response = $this->get('api/events/'.$event->id.'/invite/'.$userTwo->id);
$response = $this->post('api/events/'.$event->id.'/invite/'.$userTwo->id);
$response->assertStatus(200);
$response->assertJson([
'data' => [
@@ -441,7 +441,7 @@ class EventsTest extends TestCase
$userTwo = factory(User::class)->create();
$event->guests()->attach($userTwo);
$response = $this->get('api/events/'.$event->id.'/staff/'.$userTwo->id);
$response = $this->post('api/events/'.$event->id.'/staff/'.$userTwo->id);
$response->assertStatus(200);
$response->assertJson([
'data' => [
@@ -468,9 +468,90 @@ class EventsTest extends TestCase
]);
}
// owner_can_remove_guest_to_staff_event
/** @test */
public function owner_can_remove_guest_to_staff_event()
{
$this->withoutExceptionHandling();
$this->actingAs($user = factory(User::class)->create(), 'api');
$event = factory(Event::class)->create(['user_id' => $user->id]);
$userTwo = factory(User::class)->create();
$event->guests()->attach($userTwo);
// staff_can_add_guest
$response = $this->delete('api/events/'.$event->id.'/staff/'.$userTwo->id);
$response->assertStatus(200);
$response->assertJson([
'data' => [
'event_id' => $event->id,
'attributes' => [
'data' => [
'invitations' => [
[
'data' => [
'user_id' => $userTwo->id,
'attributes' => [
'is_staff' => false,
]
],
'links' => [
'self' => url('/users/'.$userTwo->id),
],
]
],
]
]
]
]);
}
/** @test */
public function staff_can_add_guest()
{
$this->withoutExceptionHandling();
$user = factory(User::class)->create();
$event = factory(Event::class)->create(['user_id' => $user->id]);
$this->actingAs($userTwo = factory(User::class)->create(), 'api');
$event->guests()->attach($userTwo);
$event->guests()->updateExistingPivot($userTwo, ['is_staff' => true], false);
$nexGuestUser = factory(User::class)->create();
$response = $this->post('api/events/'.$event->id.'/invite/'.$nexGuestUser->id);
$event = $event->fresh();
$response->assertStatus(200);
$this->assertCount(2, $event->guests);
$response->assertJson([
'data' => [
'event_id' => $event->id,
'attributes' => [
'data' => [
'invitations' => [
[
'data' => [
'user_id' => $userTwo->id,
'attributes' => [
'is_staff' => 1,
]
],
],
[
'data' => [
'user_id' => $nexGuestUser->id,
'attributes' => [
'is_staff' => 0,
]
]
]
],
]
]
]
]);
}
// guest_can_invite_another_guest_if_public_event
// guest_can_validate_event_participation