Rename getTalks function
This commit is contained in:
parent
d57b8ccae0
commit
7955042ec0
|
@ -29,7 +29,7 @@ class TalksExtension extends AbstractExtension
|
||||||
public function getFunctions()
|
public function getFunctions()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
new TwigFunction('getTalks', [$this, 'getTalks']),
|
new TwigFunction('get_all_talks', [$this, 'getAllTalks']),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ class TalksExtension extends AbstractExtension
|
||||||
*
|
*
|
||||||
* @return Collection A sorted collection of talks.
|
* @return Collection A sorted collection of talks.
|
||||||
*/
|
*/
|
||||||
public function getTalks($talks): Collection
|
public function getAllTalks($talks): Collection
|
||||||
{
|
{
|
||||||
return (new Collection($talks))->sortBy(function ($talk) {
|
return (new Collection($talks))->sortBy(function ($talk) {
|
||||||
return $this->getLastDate($talk);
|
return $this->getLastDate($talk);
|
||||||
|
|
|
@ -49,7 +49,7 @@ class RetrievingEventsTest extends TestCase
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$talks = $this->extension->getTalks([$talkA, $talkB]);
|
$talks = $this->extension->getAllTalks([$talkA, $talkB]);
|
||||||
$events = $this->extension->filterPastEvents($talks);
|
$events = $this->extension->filterPastEvents($talks);
|
||||||
|
|
||||||
$this->assertInstanceOf(Collection::class, $talks);
|
$this->assertInstanceOf(Collection::class, $talks);
|
||||||
|
@ -85,7 +85,7 @@ class RetrievingEventsTest extends TestCase
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$talks = $this->extension->getTalks([$talkA, $talkB]);
|
$talks = $this->extension->getAllTalks([$talkA, $talkB]);
|
||||||
$events = $this->extension->filterUpcomingEvents($talks);
|
$events = $this->extension->filterUpcomingEvents($talks);
|
||||||
|
|
||||||
$this->assertInstanceOf(Collection::class, $talks);
|
$this->assertInstanceOf(Collection::class, $talks);
|
||||||
|
|
|
@ -40,7 +40,7 @@ class RetrievingTalksTest extends TestCase
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->assertCount(2, $this->extension->getTalks([$talkA, $talkB]));
|
$this->assertCount(2, $this->extension->getAllTalks([$talkA, $talkB]));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
|
@ -69,7 +69,7 @@ class RetrievingTalksTest extends TestCase
|
||||||
];
|
];
|
||||||
|
|
||||||
$unorderedTalks = [$talkC, $talkA, $talkB];
|
$unorderedTalks = [$talkC, $talkA, $talkB];
|
||||||
$orderedTalks = $this->extension->getTalks($unorderedTalks);
|
$orderedTalks = $this->extension->getAllTalks($unorderedTalks);
|
||||||
|
|
||||||
$this->assertEquals([$talkC, $talkA, $talkB], $orderedTalks->toArray());
|
$this->assertEquals([$talkC, $talkA, $talkB], $orderedTalks->toArray());
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ class RetrievingTalksTest extends TestCase
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$talks = $this->extension->getTalks([$pastTalk, $futureTalk]);
|
$talks = $this->extension->getAllTalks([$pastTalk, $futureTalk]);
|
||||||
$filtered = $this->extension->filterPastTalks($talks);
|
$filtered = $this->extension->filterPastTalks($talks);
|
||||||
|
|
||||||
$this->assertCount(1, $filtered);
|
$this->assertCount(1, $filtered);
|
||||||
|
@ -122,7 +122,7 @@ class RetrievingTalksTest extends TestCase
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$talks = $this->extension->getTalks([$pastTalk, $todayTalk, $futureTalk]);
|
$talks = $this->extension->getAllTalks([$pastTalk, $todayTalk, $futureTalk]);
|
||||||
$filtered = $this->extension->filterUpcomingTalks($talks);
|
$filtered = $this->extension->filterUpcomingTalks($talks);
|
||||||
|
|
||||||
$this->assertSame(2, $filtered->count());
|
$this->assertSame(2, $filtered->count());
|
||||||
|
@ -140,7 +140,7 @@ class RetrievingTalksTest extends TestCase
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$talks = $this->extension->getTalks([$talk]);
|
$talks = $this->extension->getAllTalks([$talk]);
|
||||||
|
|
||||||
$this->assertCount(1, $this->extension->filterUpcomingTalks($talks));
|
$this->assertCount(1, $this->extension->filterUpcomingTalks($talks));
|
||||||
$this->assertEmpty($this->extension->filterPastTalks($talks));
|
$this->assertEmpty($this->extension->filterPastTalks($talks));
|
||||||
|
|
|
@ -24,7 +24,7 @@ talks:
|
||||||
date: 2018-06-27
|
date: 2018-06-27
|
||||||
---
|
---
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% set talks = getTalks(page.talks|merge(data.talks)) %}
|
{% set talks = get_all_talks(page.talks|merge(data.talks)) %}
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<p class="lead">
|
<p class="lead">
|
||||||
|
|
Loading…
Reference in a new issue