diff --git a/src/EventRepository.php b/src/EventRepository.php index 23b0e02..479f53f 100644 --- a/src/EventRepository.php +++ b/src/EventRepository.php @@ -6,5 +6,5 @@ use Illuminate\Support\Collection; interface EventRepository { - public function findAttendeesForEvent(): Collection; + public function findAttendeesForEvent(int $eventId): Collection; } diff --git a/src/Meetup/MeetupApiEventRepository.php b/src/Meetup/MeetupApiEventRepository.php index 494c01e..81c454f 100644 --- a/src/Meetup/MeetupApiEventRepository.php +++ b/src/Meetup/MeetupApiEventRepository.php @@ -16,9 +16,11 @@ final class MeetupApiEventRepository implements EventRepository $this->client = $client; } - public function findAttendeesForEvent(): Collection + public function findAttendeesForEvent(int $eventId): Collection { - $response = $this->client->request('GET', 'https://api.meetup.com/php-south-wales/events/282265786/rsvps'); + $apiUrl = sprintf('https://api.meetup.com/%s/events/%d/rsvps', 'php-south-wales', $eventId); + + $response = $this->client->request('GET', $apiUrl); $rsvps = json_decode($response->getContent()); diff --git a/tests/EventRepositoryContractTest.php b/tests/EventRepositoryContractTest.php index 45fb1ae..c5a4566 100644 --- a/tests/EventRepositoryContractTest.php +++ b/tests/EventRepositoryContractTest.php @@ -12,7 +12,7 @@ trait EventRepositoryContractTest /** @test */ public function should_only_return_attendees_with_a_yes_rsvp(): void { - $attendees = $this->repository->findAttendeesForEvent(); + $attendees = $this->repository->findAttendeesForEvent(self::$eventId); $this->assertOnlyAttendingAttendeesAreReturned($attendees); } @@ -20,7 +20,7 @@ trait EventRepositoryContractTest /** @test */ public function should_not_return_event_organisers(): void { - $attendees = $this->repository->findAttendeesForEvent(); + $attendees = $this->repository->findAttendeesForEvent(static::$eventId); $this->assertEventHostsAreNotReturned($attendees); } diff --git a/tests/Fake/FakeEventRepository.php b/tests/Fake/FakeEventRepository.php index dba2cce..b87a456 100644 --- a/tests/Fake/FakeEventRepository.php +++ b/tests/Fake/FakeEventRepository.php @@ -22,7 +22,7 @@ final class FakeEventRepository implements EventRepository ]; } - public function findAttendeesForEvent(): Collection + public function findAttendeesForEvent(int $eventId): Collection { return Collection::make(self::$rsvps) ->filter(fn (\stdClass $attendee): bool => $attendee->is_attending) diff --git a/tests/Fake/FakeEventRepositoryTest.php b/tests/Fake/FakeEventRepositoryTest.php index 27a3617..ea0e66d 100644 --- a/tests/Fake/FakeEventRepositoryTest.php +++ b/tests/Fake/FakeEventRepositoryTest.php @@ -10,6 +10,8 @@ final class FakeEventRepositoryTest extends KernelTestCase { use EventRepositoryContractTest; + public static int $eventId = 123; + private EventRepository $repository; public function setUp(): void diff --git a/tests/Meetup/MeetupApiEventRepositoryTest.php b/tests/Meetup/MeetupApiEventRepositoryTest.php index c595021..251586b 100644 --- a/tests/Meetup/MeetupApiEventRepositoryTest.php +++ b/tests/Meetup/MeetupApiEventRepositoryTest.php @@ -13,6 +13,8 @@ final class MeetupApiEventRepositoryTest extends KernelTestCase { use EventRepositoryContractTest; + public static int $eventId = 282265786; + private EventRepository $repository; public function setUp(): void