From 7955042ec06395fd6bb670019c2d848aec39f817 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 27 Dec 2019 12:42:05 +0000 Subject: [PATCH] Rename getTalks function --- app/src/Talk/TwigExtension/TalksExtension.php | 4 ++-- app/tests/Talk/TwigExtension/RetrievingEventsTest.php | 4 ++-- app/tests/Talk/TwigExtension/RetrievingTalksTest.php | 10 +++++----- source/_pages/talks.html.twig | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/Talk/TwigExtension/TalksExtension.php b/app/src/Talk/TwigExtension/TalksExtension.php index 0f2da16d..fa32e862 100644 --- a/app/src/Talk/TwigExtension/TalksExtension.php +++ b/app/src/Talk/TwigExtension/TalksExtension.php @@ -29,7 +29,7 @@ class TalksExtension extends AbstractExtension public function getFunctions() { 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. */ - public function getTalks($talks): Collection + public function getAllTalks($talks): Collection { return (new Collection($talks))->sortBy(function ($talk) { return $this->getLastDate($talk); diff --git a/app/tests/Talk/TwigExtension/RetrievingEventsTest.php b/app/tests/Talk/TwigExtension/RetrievingEventsTest.php index f940ee08..df9a6b4b 100644 --- a/app/tests/Talk/TwigExtension/RetrievingEventsTest.php +++ b/app/tests/Talk/TwigExtension/RetrievingEventsTest.php @@ -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); $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); $this->assertInstanceOf(Collection::class, $talks); diff --git a/app/tests/Talk/TwigExtension/RetrievingTalksTest.php b/app/tests/Talk/TwigExtension/RetrievingTalksTest.php index da1dd320..8ca148a5 100644 --- a/app/tests/Talk/TwigExtension/RetrievingTalksTest.php +++ b/app/tests/Talk/TwigExtension/RetrievingTalksTest.php @@ -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 */ @@ -69,7 +69,7 @@ class RetrievingTalksTest extends TestCase ]; $unorderedTalks = [$talkC, $talkA, $talkB]; - $orderedTalks = $this->extension->getTalks($unorderedTalks); + $orderedTalks = $this->extension->getAllTalks($unorderedTalks); $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); $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); $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->assertEmpty($this->extension->filterPastTalks($talks)); diff --git a/source/_pages/talks.html.twig b/source/_pages/talks.html.twig index c78fa7a6..311d26fd 100644 --- a/source/_pages/talks.html.twig +++ b/source/_pages/talks.html.twig @@ -24,7 +24,7 @@ talks: date: 2018-06-27 --- {% block content %} - {% set talks = getTalks(page.talks|merge(data.talks)) %} + {% set talks = get_all_talks(page.talks|merge(data.talks)) %}