refactor: move methods into a contract test trait
This commit is contained in:
parent
c25104c321
commit
21aa911fb4
26
tests/EventRepositoryContractTest.php
Normal file
26
tests/EventRepositoryContractTest.php
Normal 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);
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue