Change filters into functions

This commit is contained in:
Oliver Davies 2019-12-27 13:56:51 +00:00
parent 7955042ec0
commit 1c3d7f820f
4 changed files with 39 additions and 90 deletions

View file

@ -50,43 +50,7 @@ class RetrievingEventsTest extends TestCase
];
$talks = $this->extension->getAllTalks([$talkA, $talkB]);
$events = $this->extension->filterPastEvents($talks);
$this->assertInstanceOf(Collection::class, $talks);
$this->assertInstanceOf(Collection::class, $events);
$this->assertCount(2, $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->getAllTalks([$talkA, $talkB]);
$events = $this->extension->filterUpcomingEvents($talks);
$events = $this->extension->getPastEvents($talks);
$this->assertInstanceOf(Collection::class, $talks);
$this->assertInstanceOf(Collection::class, $events);

View file

@ -91,11 +91,9 @@ class RetrievingTalksTest extends TestCase
],
];
$talks = $this->extension->getAllTalks([$pastTalk, $futureTalk]);
$filtered = $this->extension->filterPastTalks($talks);
$this->assertCount(1, $filtered);
$this->assertSame($pastTalk, $filtered->first());
$talks = $this->extension->getPastTalks([$pastTalk, $futureTalk]);
$this->assertCount(1, $talks);
$this->assertSame($pastTalk, $talks->first());
}
/** @test */
@ -122,11 +120,9 @@ class RetrievingTalksTest extends TestCase
],
];
$talks = $this->extension->getAllTalks([$pastTalk, $todayTalk, $futureTalk]);
$filtered = $this->extension->filterUpcomingTalks($talks);
$this->assertSame(2, $filtered->count());
$this->assertSame([$todayTalk, $futureTalk], $filtered->toArray());
$talks = $this->extension->getUpcomingTalks([$pastTalk, $todayTalk, $futureTalk]);
$this->assertSame(2, $talks->count());
$this->assertSame([$todayTalk, $futureTalk], $talks->toArray());
}
/** @test */
@ -140,10 +136,8 @@ class RetrievingTalksTest extends TestCase
],
];
$talks = $this->extension->getAllTalks([$talk]);
$this->assertCount(1, $this->extension->filterUpcomingTalks($talks));
$this->assertEmpty($this->extension->filterPastTalks($talks));
$this->assertCount(1, $this->extension->getUpcomingTalks([$talk]));
$this->assertEmpty($this->extension->getPastTalks([$talk]));
}
/** @test */