refactor: extract custom assertions
This commit is contained in:
parent
8fe80b8992
commit
c1606b4868
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Tests;
|
namespace App\Tests;
|
||||||
|
|
||||||
use App\EventRepository;
|
use App\EventRepository;
|
||||||
|
use Tightenco\Collect\Support\Collection;
|
||||||
|
|
||||||
trait EventRepositoryContractTest
|
trait EventRepositoryContractTest
|
||||||
{
|
{
|
||||||
|
@ -13,7 +14,7 @@ trait EventRepositoryContractTest
|
||||||
{
|
{
|
||||||
$attendees = $this->repository->findAttendeesForEvent();
|
$attendees = $this->repository->findAttendeesForEvent();
|
||||||
|
|
||||||
$this->assertFalse($attendees->pluck('is_attending')->contains(false));
|
$this->assertOnlyAttendingAttendeesAreReturned($attendees);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
|
@ -21,6 +22,16 @@ trait EventRepositoryContractTest
|
||||||
{
|
{
|
||||||
$attendees = $this->repository->findAttendeesForEvent();
|
$attendees = $this->repository->findAttendeesForEvent();
|
||||||
|
|
||||||
|
$this->assertEventHostsAreNotReturned($attendees);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function assertEventHostsAreNotReturned(Collection $attendees): void
|
||||||
|
{
|
||||||
$this->assertSame([false], $attendees->pluck('is_host')->unique()->toArray());
|
$this->assertSame([false], $attendees->pluck('is_host')->unique()->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function assertOnlyAttendingAttendeesAreReturned(Collection $attendees): void
|
||||||
|
{
|
||||||
|
$this->assertFalse($attendees->pluck('is_attending')->contains(false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue