meetup-raffle-winner-picker/tests/EventRepositoryContractTest.php

38 lines
995 B
PHP
Raw Normal View History

<?php
namespace App\Tests;
use App\EventRepository;
2022-01-14 00:24:22 +00:00
use Tightenco\Collect\Support\Collection;
trait EventRepositoryContractTest
{
private EventRepository $repository;
/** @test */
public function should_only_return_attendees_with_a_yes_rsvp(): void
{
2022-01-14 00:14:08 +00:00
$attendees = $this->repository->findAttendeesForEvent();
2022-01-14 00:24:22 +00:00
$this->assertOnlyAttendingAttendeesAreReturned($attendees);
}
/** @test */
public function should_not_return_event_organisers(): void
{
2022-01-14 00:14:08 +00:00
$attendees = $this->repository->findAttendeesForEvent();
2022-01-14 00:24:22 +00:00
$this->assertEventHostsAreNotReturned($attendees);
}
private function assertEventHostsAreNotReturned(Collection $attendees): void
{
$this->assertSame([false], $attendees->pluck('is_host')->unique()->toArray());
}
2022-01-14 00:24:22 +00:00
private function assertOnlyAttendingAttendeesAreReturned(Collection $attendees): void
{
$this->assertFalse($attendees->pluck('is_attending')->contains(false));
}
}