refactor(meetup): specify the event ID
This commit is contained in:
parent
bb14c14b32
commit
24151c26ec
|
@ -6,5 +6,5 @@ use Illuminate\Support\Collection;
|
|||
|
||||
interface EventRepository
|
||||
{
|
||||
public function findAttendeesForEvent(): Collection;
|
||||
public function findAttendeesForEvent(int $eventId): Collection;
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -10,6 +10,8 @@ final class FakeEventRepositoryTest extends KernelTestCase
|
|||
{
|
||||
use EventRepositoryContractTest;
|
||||
|
||||
public static int $eventId = 123;
|
||||
|
||||
private EventRepository $repository;
|
||||
|
||||
public function setUp(): void
|
||||
|
|
|
@ -13,6 +13,8 @@ final class MeetupApiEventRepositoryTest extends KernelTestCase
|
|||
{
|
||||
use EventRepositoryContractTest;
|
||||
|
||||
public static int $eventId = 282265786;
|
||||
|
||||
private EventRepository $repository;
|
||||
|
||||
public function setUp(): void
|
||||
|
|
Loading…
Reference in a new issue