From 9d880841ea61fb68af3361f9043a5e700498c104 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 13 Jan 2022 21:06:46 +0000 Subject: [PATCH] refactor: move the repository into a setUp method --- tests/FakeEventRepositoryTest.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/FakeEventRepositoryTest.php b/tests/FakeEventRepositoryTest.php index 4462bd8..7511c9f 100644 --- a/tests/FakeEventRepositoryTest.php +++ b/tests/FakeEventRepositoryTest.php @@ -7,12 +7,19 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; final class FakeEventRepositoryTest extends KernelTestCase { + private EventRepository $repository; + + public function setUp(): void + { + self::bootKernel(); + + $this->repository = static::$container->get(EventRepository::class); + } + /** @test */ public function should_only_return_attendees_with_a_yes_rsvp(): void { - $container = self::bootKernel()->getContainer(); - $repository = $container->get(EventRepository::class); - $attendees = $repository->getConfirmedAttendees(); + $attendees = $this->repository->getConfirmedAttendees(); $this->assertCount(3, $attendees->pluck('name')); }