Add filters for upcoming and past events

This commit is contained in:
Oliver Davies 2019-05-20 12:55:18 +01:00
parent e94ff3addd
commit 394be76029
2 changed files with 100 additions and 10 deletions

View file

@ -49,6 +49,80 @@ class RetrievingEventsTest extends TestCase
],
];
$this->assertCount(3, $this->extension->getEvents([$talkA, $talkB]));
$talks = $this->extension->getTalks([$talkA, $talkB]);
$this->assertInstanceOf(Collection::class, $talks);
$this->assertCount(3, $this->extension->getEvents($talks));
}
/** @test */
public function get_past_events()
{
$talkA = [
'title' => 'Test Driven Drupal',
'events' => [
[
'event' => 'php_south_wales',
'date' => (new DateTime('+1 days'))->getTimestamp(),
],
[
'event' => 'drupalcamp_london',
'date' => (new DateTime('-1 days'))->getTimestamp(),
],
],
];
$talkB = [
'title' => 'Taking Flight with Tailwind CSS',
'events' => [
[
'event' => 'blue_conf_2019',
'date' => (new DateTime('-2 days'))->getTimestamp(),
],
],
];
$talks = $this->extension->getTalks([$talkA, $talkB]);
$events = $this->extension->getEvents($talks);
$this->assertInstanceOf(Collection::class, $talks);
$this->assertInstanceOf(Collection::class, $events);
$this->assertCount(2, $this->extension->filterPastEvents($events));
}
/** @test */
public function get_current_or_upcoming_events()
{
$talkA = [
'title' => 'Test Driven Drupal',
'events' => [
[
'event' => 'php_south_wales',
'date' => (new DateTime('+0 days'))->getTimestamp(),
],
[
'event' => 'drupalcamp_london',
'date' => (new DateTime('-1 days'))->getTimestamp(),
],
],
];
$talkB = [
'title' => 'Taking Flight with Tailwind CSS',
'events' => [
[
'event' => 'blue_conf_2019',
'date' => (new DateTime('+2 days'))->getTimestamp(),
],
],
];
$talks = $this->extension->getTalks([$talkA, $talkB]);
$events = $this->extension->getEvents($talks);
$this->assertInstanceOf(Collection::class, $talks);
$this->assertInstanceOf(Collection::class, $events);
$this->assertCount(2, $this->extension->filterUpcomingEvents($events));
}
}