From 21aa911fb43e91b958c7070ba4e73d19724e3e90 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 13 Jan 2022 22:03:50 +0000 Subject: [PATCH] refactor: move methods into a contract test trait --- tests/EventRepositoryContractTest.php | 26 ++++++++++++++++++++++++++ tests/FakeEventRepositoryTest.php | 18 ++---------------- 2 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 tests/EventRepositoryContractTest.php diff --git a/tests/EventRepositoryContractTest.php b/tests/EventRepositoryContractTest.php new file mode 100644 index 0000000..d763d11 --- /dev/null +++ b/tests/EventRepositoryContractTest.php @@ -0,0 +1,26 @@ +repository->getConfirmedAttendees(); + + $this->assertCount(3, $attendees); + } + + /** @test */ + public function should_not_return_event_organisers(): void + { + $attendees = $this->repository->getConfirmedAttendees(); + + $this->assertCount(3, $attendees); + } +} diff --git a/tests/FakeEventRepositoryTest.php b/tests/FakeEventRepositoryTest.php index a18bf13..2c68065 100644 --- a/tests/FakeEventRepositoryTest.php +++ b/tests/FakeEventRepositoryTest.php @@ -7,6 +7,8 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; final class FakeEventRepositoryTest extends KernelTestCase { + use EventRepositoryContractTest; + private EventRepository $repository; public function setUp(): void @@ -15,20 +17,4 @@ final class FakeEventRepositoryTest extends KernelTestCase $this->repository = static::$container->get(EventRepository::class); } - - /** @test */ - public function should_only_return_attendees_with_a_yes_rsvp(): void - { - $attendees = $this->repository->getConfirmedAttendees(); - - $this->assertCount(3, $attendees); - } - - /** @test */ - public function should_not_return_event_organisers(): void - { - $attendees = $this->repository->getConfirmedAttendees(); - - $this->assertCount(3, $attendees); - } }