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;
use Tightenco\Collect\Support\Collection;
interface EventRepository
{
public function getConfirmedAttendees(): array;
public function getConfirmedAttendees(): Collection;
}

View file

@ -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.'],
]);
}
}

View file

@ -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'));
}