Count the number of events from talks
This commit is contained in:
parent
5048781ae3
commit
92f3865ee7
|
@ -2,10 +2,10 @@
|
||||||
title: Talks and workshops
|
title: Talks and workshops
|
||||||
use:
|
use:
|
||||||
- talks
|
- talks
|
||||||
intro_text: |
|
|
||||||
Starting with my first talk in September 2012, I have given 82 presentations and workshops at various conferences and meetups, in-person and remotely, on topics including PHP, Drupal, automated testing, Git, CSS, and systems administration.
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
<p>Starting with my first talk in September 2012, I have given {{ get_past_talk_count(data.talks) }} presentations and workshops at various conferences and meetups, in-person and remotely, on topics including PHP, Drupal, automated testing, Git, CSS, and systems administration.</p>
|
||||||
|
|
||||||
<div class="mt-10">
|
<div class="mt-10">
|
||||||
<div class="space-y-8">
|
<div class="space-y-8">
|
||||||
{% for talk in data.talks|sort((a,b) => a.sortable_date < b.sortable_date) %}
|
{% for talk in data.talks|sort((a,b) => a.sortable_date < b.sortable_date) %}
|
||||||
|
|
|
@ -17,10 +17,16 @@ final class TalkExtension extends AbstractExtension
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPastTalkCount(array $talks = []): int
|
public function getPastTalkCount(iterable $talks = []): int
|
||||||
|
{
|
||||||
|
return $this->getEventsFromTalks($talks)->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getEventsFromTalks(iterable $talks): Collection
|
||||||
{
|
{
|
||||||
$talkCollection = new Collection($talks);
|
$talkCollection = new Collection($talks);
|
||||||
|
|
||||||
return $talkCollection->count();
|
return $talkCollection
|
||||||
|
->flatMap(fn($talk): array => (array) $talk['events']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,49 @@ use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
final class TalkExtensionTest extends TestCase
|
final class TalkExtensionTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private TalkExtension $subject;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
$this->subject = new TalkExtension();
|
||||||
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function it_returns_zero_if_there_are_no_talks(): void
|
public function it_returns_zero_if_there_are_no_talks(): void
|
||||||
{
|
{
|
||||||
$this->assertSame(0, (new TalkExtension())->getPastTalkCount([]));
|
$this->assertSame(0, $this->subject->getPastTalkCount([]));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function it_counts_a_single_event_from_a_single_talk(): void
|
||||||
|
{
|
||||||
|
$talks = [
|
||||||
|
[
|
||||||
|
'title' => 'Building static sites with Sculpin',
|
||||||
|
'events' => [
|
||||||
|
'',
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
$this->assertSame(1, $this->subject->getPastTalkCount($talks));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function it_counts_multiple_events_from_a_single_talk(): void
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function it_counts_multiple_events_from_multiple_talks(): void
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @test */
|
||||||
|
public function it_excludes_future_talks(): void
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue