From 7b5da6e46a3ed4ca03464dd75453244839841f54 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 13 Jan 2022 20:36:10 +0000 Subject: [PATCH] refactor: move attendees into the fake repository --- src/EventRepository.php | 4 +++- tests/FakeEventRepository.php | 9 +++++++-- tests/FakeEventRepositoryTest.php | 8 ++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/EventRepository.php b/src/EventRepository.php index e1f5fec..debd1a8 100644 --- a/src/EventRepository.php +++ b/src/EventRepository.php @@ -2,7 +2,9 @@ namespace App; +use Tightenco\Collect\Support\Collection; + interface EventRepository { - public function getConfirmedAttendees(): array; + public function getConfirmedAttendees(): Collection; } diff --git a/tests/FakeEventRepository.php b/tests/FakeEventRepository.php index d1d93fd..e570334 100644 --- a/tests/FakeEventRepository.php +++ b/tests/FakeEventRepository.php @@ -5,10 +5,15 @@ declare(strict_types=1); namespace App\Tests; use App\EventRepository; +use Tightenco\Collect\Support\Collection; final class FakeEventRepository implements EventRepository { - public function getConfirmedAttendees(): array { - return []; + public function getConfirmedAttendees(): Collection { + return Collection::make([ + ['name' => 'matthew s.'], + ['name' => 'Michael P.'], + ['name' => 'Kathryn "Kat" R.'], + ]); } } diff --git a/tests/FakeEventRepositoryTest.php b/tests/FakeEventRepositoryTest.php index f988a1f..1c298d4 100644 --- a/tests/FakeEventRepositoryTest.php +++ b/tests/FakeEventRepositoryTest.php @@ -3,17 +3,13 @@ namespace App\Tests; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -use Tightenco\Collect\Support\Collection; final class FakeEventRepositoryTest extends KernelTestCase { /** @test */ public function should_only_return_attendees_with_a_yes_rsvp(): void { - $attendees = Collection::make([ - ['name' => 'matthew s.'], - ['name' => 'Michael P.'], - ['name' => 'Kathryn "Kat" R.'], - ]); + $repository = new FakeEventRepository(); + $attendees = $repository->getConfirmedAttendees(); $this->assertCount(3, $attendees->pluck('name')); }