refactor: move methods into a contract test trait

This commit is contained in:
Oliver Davies 2022-01-13 22:03:50 +00:00
parent c25104c321
commit 21aa911fb4
2 changed files with 28 additions and 16 deletions

View file

@ -0,0 +1,26 @@
<?php
namespace App\Tests;
use App\EventRepository;
trait EventRepositoryContractTest
{
private EventRepository $repository;
/** @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);
}
}

View file

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