Update tests
This commit is contained in:
parent
54fd609c5b
commit
df7b6315ba
|
@ -105,4 +105,9 @@ class TalksExtension extends AbstractExtension
|
|||
return $talk['events'];
|
||||
});
|
||||
}
|
||||
|
||||
public function getAllEvents($talks): array
|
||||
{
|
||||
return $this->eventsFromTalks($talks)->toArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,38 +22,6 @@ class RetrievingEventsTest extends TestCase
|
|||
$this->extension = new TalksExtension();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function getting_all_events()
|
||||
{
|
||||
$talkA = [
|
||||
'title' => 'Talk A',
|
||||
'events' => [
|
||||
[
|
||||
'event' => 'event_a',
|
||||
'date' => (new DateTime('-1 days'))->getTimestamp()
|
||||
],
|
||||
[
|
||||
'event' => 'event_b',
|
||||
'date' => (new DateTime('+1 days'))->getTimestamp()
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$talkB = [
|
||||
'title' => 'Talk B',
|
||||
'events' => [
|
||||
[
|
||||
'event' => 'event_a',
|
||||
'date' => (new DateTime('-3 days'))->getTimestamp()
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$talks = $this->extension->getTalks([$talkA, $talkB]);
|
||||
$this->assertInstanceOf(Collection::class, $talks);
|
||||
$this->assertCount(3, $this->extension->getEvents($talks));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function get_past_events()
|
||||
{
|
||||
|
@ -82,12 +50,12 @@ class RetrievingEventsTest extends TestCase
|
|||
];
|
||||
|
||||
$talks = $this->extension->getTalks([$talkA, $talkB]);
|
||||
$events = $this->extension->getEvents($talks);
|
||||
$events = $this->extension->filterPastEvents($talks);
|
||||
|
||||
$this->assertInstanceOf(Collection::class, $talks);
|
||||
$this->assertInstanceOf(Collection::class, $events);
|
||||
$this->assertTrue(is_array($events));
|
||||
|
||||
$this->assertCount(2, $this->extension->filterPastEvents($events));
|
||||
$this->assertCount(2, $events);
|
||||
}
|
||||
/** @test */
|
||||
public function get_current_or_upcoming_events()
|
||||
|
@ -118,11 +86,11 @@ class RetrievingEventsTest extends TestCase
|
|||
|
||||
|
||||
$talks = $this->extension->getTalks([$talkA, $talkB]);
|
||||
$events = $this->extension->getEvents($talks);
|
||||
$events = $this->extension->filterUpcomingEvents($talks);
|
||||
|
||||
$this->assertInstanceOf(Collection::class, $talks);
|
||||
$this->assertInstanceOf(Collection::class, $events);
|
||||
$this->assertTrue(is_array($events));
|
||||
|
||||
$this->assertCount(2, $this->extension->filterUpcomingEvents($events));
|
||||
$this->assertCount(2, $events);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,10 +92,10 @@ class RetrievingTalksTest extends TestCase
|
|||
];
|
||||
|
||||
$talks = $this->extension->getTalks([$pastTalk, $futureTalk]);
|
||||
$filtered = $this->extension->filterPast($talks);
|
||||
$filtered = $this->extension->filterPastTalks($talks);
|
||||
|
||||
$this->assertCount(1, $filtered);
|
||||
$this->assertSame($pastTalk, $filtered->first());
|
||||
$this->assertSame($pastTalk, $filtered[0]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
@ -123,10 +123,10 @@ class RetrievingTalksTest extends TestCase
|
|||
];
|
||||
|
||||
$talks = $this->extension->getTalks([$pastTalk, $todayTalk, $futureTalk]);
|
||||
$filtered = $this->extension->filterUpcoming($talks);
|
||||
$filtered = $this->extension->filterUpcomingTalks($talks);
|
||||
|
||||
$this->assertCount(2, $filtered);
|
||||
$this->assertSame([$todayTalk, $futureTalk], $filtered->toArray());
|
||||
$this->assertSame([$todayTalk, $futureTalk], $filtered);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
@ -142,8 +142,8 @@ class RetrievingTalksTest extends TestCase
|
|||
|
||||
$talks = $this->extension->getTalks([$talk]);
|
||||
|
||||
$this->assertCount(1, $this->extension->filterUpcoming($talks));
|
||||
$this->assertEmpty($this->extension->filterPast($talks));
|
||||
$this->assertCount(1, $this->extension->filterUpcomingTalks($talks));
|
||||
$this->assertEmpty($this->extension->filterPastTalks($talks));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
@ -166,7 +166,9 @@ class RetrievingTalksTest extends TestCase
|
|||
|
||||
$talks = collect([$talkA, $talkB]);
|
||||
|
||||
tap($this->extension->getEvents($talks), function (Collection $events) {
|
||||
tap($this->extension->getAllEvents($talks), function (array $events) {
|
||||
$events = collect($events);
|
||||
|
||||
$this->assertCount(3, $events);
|
||||
|
||||
$this->assertSame(
|
||||
|
|
Reference in a new issue