refactor: move attendees into the fake repository

This commit is contained in:
Oliver Davies 2022-01-13 20:36:10 +00:00
parent f192dd720c
commit 7b5da6e46a
3 changed files with 12 additions and 9 deletions

View file

@ -2,7 +2,9 @@
namespace App; namespace App;
use Tightenco\Collect\Support\Collection;
interface EventRepository interface EventRepository
{ {
public function getConfirmedAttendees(): array; public function getConfirmedAttendees(): Collection;
} }

View file

@ -5,10 +5,15 @@ declare(strict_types=1);
namespace App\Tests; namespace App\Tests;
use App\EventRepository; use App\EventRepository;
use Tightenco\Collect\Support\Collection;
final class FakeEventRepository implements EventRepository final class FakeEventRepository implements EventRepository
{ {
public function getConfirmedAttendees(): array { public function getConfirmedAttendees(): Collection {
return []; return Collection::make([
['name' => 'matthew s.'],
['name' => 'Michael P.'],
['name' => 'Kathryn "Kat" R.'],
]);
} }
} }

View file

@ -3,17 +3,13 @@
namespace App\Tests; namespace App\Tests;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Tightenco\Collect\Support\Collection;
final class FakeEventRepositoryTest extends KernelTestCase final class FakeEventRepositoryTest extends KernelTestCase
{ {
/** @test */ /** @test */
public function should_only_return_attendees_with_a_yes_rsvp(): void { public function should_only_return_attendees_with_a_yes_rsvp(): void {
$attendees = Collection::make([ $repository = new FakeEventRepository();
['name' => 'matthew s.'], $attendees = $repository->getConfirmedAttendees();
['name' => 'Michael P.'],
['name' => 'Kathryn "Kat" R.'],
]);
$this->assertCount(3, $attendees->pluck('name')); $this->assertCount(3, $attendees->pluck('name'));
} }