Events with no date are not returned
GH-160
This commit is contained in:
parent
1c3d7f820f
commit
2133af2a4a
|
@ -99,6 +99,8 @@ class TalksExtension extends AbstractExtension
|
||||||
{
|
{
|
||||||
return (new Collection($talks))->flatMap(function ($talk): array {
|
return (new Collection($talks))->flatMap(function ($talk): array {
|
||||||
return $talk['events'];
|
return $talk['events'];
|
||||||
|
})->filter(function ($event): bool {
|
||||||
|
return !empty($event['date']);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,4 +57,30 @@ class RetrievingEventsTest extends TestCase
|
||||||
|
|
||||||
$this->assertCount(2, $events);
|
$this->assertCount(2, $events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function events_with_no_date_are_not_returned()
|
||||||
|
{
|
||||||
|
$talks = [
|
||||||
|
[
|
||||||
|
'title' => 'Deploying PHP applications with Ansible, Ansible Vault and Ansistrano',
|
||||||
|
'events' => [
|
||||||
|
[
|
||||||
|
'event' => 'php_south_wales',
|
||||||
|
'date' => (new DateTime('-1 days'))->getTimestamp(),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'event' => 'drupal_edinburgh',
|
||||||
|
'date' => '',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->assertSame(1, $this->extension->getPastTalkCount($talks));
|
||||||
|
|
||||||
|
$pastEvents = $this->extension->getPastEvents($talks);
|
||||||
|
$this->assertCount(1, $pastEvents);
|
||||||
|
$this->assertSame('php_south_wales', $pastEvents[0]['event']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue