Ensure that talks given multiple times are only returned once
This commit is contained in:
parent
22b70033c5
commit
18e6d2e32f
|
@ -9,6 +9,8 @@ use Twig_SimpleFunction;
|
|||
|
||||
class TalksExtension extends Twig_Extension
|
||||
{
|
||||
const DATE_FORMAT = 'Y-m-d';
|
||||
|
||||
/**
|
||||
* @var string The current date.
|
||||
*/
|
||||
|
@ -34,17 +36,17 @@ class TalksExtension extends Twig_Extension
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all upcoming and previous talks.
|
||||
*
|
||||
* @param ProxySourceCollection|array $talks All talk nodes.
|
||||
* @param array $eventData Shared event data.
|
||||
*
|
||||
* @return Collection A sorted collection of talks.
|
||||
*/
|
||||
public function getAll($talks, array $eventData = [])
|
||||
/**
|
||||
* Get all upcoming and previous talks.
|
||||
*
|
||||
* @param ProxySourceCollection|array $talks All talk nodes.
|
||||
* @param array $eventData Shared event data.
|
||||
*
|
||||
* @return Collection A sorted collection of talks.
|
||||
*/
|
||||
public function getAll($talks, array $eventData = []): Collection
|
||||
{
|
||||
return $this->format($talks, $eventData)->sortBy('event.date');
|
||||
return collect($talks);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,7 +25,22 @@ class TalksExtensionTest extends TestCase
|
|||
/** @test */
|
||||
public function talks_given_multiple_times_are_only_returned_once()
|
||||
{
|
||||
$this->markTestIncomplete();
|
||||
$talkA = [
|
||||
'title' => 'Talk A',
|
||||
'events' => [
|
||||
['event' => 'event_a', 'date' => (new DateTime('-1 days'))->format(TalksExtension::DATE_FORMAT)],
|
||||
['event' => 'event_b', 'date' => (new DateTime('+1 days'))->format(TalksExtension::DATE_FORMAT)],
|
||||
],
|
||||
];
|
||||
|
||||
$talkB = [
|
||||
'title' => 'Talk B',
|
||||
'events' => [
|
||||
['event' => 'event_a', 'date' => (new DateTime('-3 days'))->format(TalksExtension::DATE_FORMAT)],
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertCount(2, $this->extension->getAll([$talkA, $talkB]));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
|
Reference in a new issue