start guest invitation on event

This commit is contained in:
2020-08-09 20:45:41 +02:00
parent fa6d769daa
commit ec837fdb0a
8 changed files with 194 additions and 0 deletions

View File

@@ -386,6 +386,96 @@ class EventsTest extends TestCase
$response->assertStatus(403);
}
/** @test */
public function owner_can_invite_user_to_an_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();
$response = $this->get('api/events/'.$event->id.'/invite/'.$userTwo->id);
$response->assertStatus(200);
$response->assertJson([
'data' => [
'event_id' => $event->id,
'attributes' => [
'data' => [
'invitations' => [
[
'data' => [
'user_id' => $userTwo->id,
]
]
],
]
]
]
]);
}
/** @test */
public function owner_can_remove_invitation()
{
$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);
$response = $this->delete('api/events/'.$event->id.'/invite/'.$userTwo->id);
$event = $event->fresh();
$this->assertCount(0, $event->guests);
$response->assertStatus(204);
}
/** @test */
public function owner_can_add_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);
$response = $this->get('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' => true,
]
],
'links' => [
'self' => url('/users/'.$userTwo->id),
],
]
],
]
]
]
]);
}
// owner_can_remove_guest_to_staff_event
// staff_can_add_guest
// guest_can_validate_event_participation
// guest_can_delete_invitation
private function data()
{
return [