2019-05-20 07:28:28 +00:00
|
|
|
<?php
|
|
|
|
|
2019-10-24 23:07:02 +00:00
|
|
|
namespace App\Tests\Talk\TwigExtension;
|
2019-05-20 07:28:28 +00:00
|
|
|
|
2019-10-24 23:07:02 +00:00
|
|
|
use App\Talk\TwigExtension\TalksExtension;
|
2019-05-20 07:28:28 +00:00
|
|
|
use DateTime;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Tightenco\Collect\Support\Collection;
|
|
|
|
|
|
|
|
class RetrievingEventsTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var TalksExtension
|
|
|
|
*/
|
|
|
|
private $extension;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
2019-10-05 18:17:58 +00:00
|
|
|
public function setUp(): void
|
2019-05-20 07:28:28 +00:00
|
|
|
{
|
|
|
|
$this->extension = new TalksExtension();
|
|
|
|
}
|
|
|
|
|
2019-05-20 11:55:18 +00:00
|
|
|
/** @test */
|
|
|
|
public function get_past_events()
|
|
|
|
{
|
|
|
|
$talkA = [
|
|
|
|
'title' => 'Test Driven Drupal',
|
|
|
|
'events' => [
|
|
|
|
[
|
|
|
|
'event' => 'php_south_wales',
|
|
|
|
'date' => (new DateTime('+1 days'))->getTimestamp(),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event' => 'drupalcamp_london',
|
|
|
|
'date' => (new DateTime('-1 days'))->getTimestamp(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$talkB = [
|
|
|
|
'title' => 'Taking Flight with Tailwind CSS',
|
|
|
|
'events' => [
|
|
|
|
[
|
|
|
|
'event' => 'blue_conf_2019',
|
|
|
|
'date' => (new DateTime('-2 days'))->getTimestamp(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
2019-12-27 12:42:05 +00:00
|
|
|
$talks = $this->extension->getAllTalks([$talkA, $talkB]);
|
2019-12-27 13:56:51 +00:00
|
|
|
$events = $this->extension->getPastEvents($talks);
|
2019-05-20 11:55:18 +00:00
|
|
|
|
|
|
|
$this->assertInstanceOf(Collection::class, $talks);
|
2019-09-27 00:51:32 +00:00
|
|
|
$this->assertInstanceOf(Collection::class, $events);
|
2019-05-20 11:55:18 +00:00
|
|
|
|
2019-05-20 19:36:23 +00:00
|
|
|
$this->assertCount(2, $events);
|
2019-05-20 07:28:28 +00:00
|
|
|
}
|
2019-12-27 15:08:01 +00:00
|
|
|
|
|
|
|
/** @test */
|
|
|
|
public function events_with_no_date_are_not_returned()
|
|
|
|
{
|
|
|
|
$talks = [
|
|
|
|
[
|
|
|
|
'title' => 'Deploying PHP applications with Ansible, Ansible Vault and Ansistrano',
|
|
|
|
'events' => [
|
|
|
|
[
|
|
|
|
'event' => 'php_south_wales',
|
|
|
|
'date' => (new DateTime('-1 days'))->getTimestamp(),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event' => 'drupal_edinburgh',
|
|
|
|
'date' => '',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$this->assertSame(1, $this->extension->getPastTalkCount($talks));
|
|
|
|
|
|
|
|
$pastEvents = $this->extension->getPastEvents($talks);
|
|
|
|
$this->assertCount(1, $pastEvents);
|
|
|
|
$this->assertSame('php_south_wales', $pastEvents[0]['event']);
|
|
|
|
}
|
2019-12-27 21:24:14 +00:00
|
|
|
|
|
|
|
/** @test */
|
|
|
|
public function get_all_of_the_events_for_a_talk()
|
|
|
|
{
|
|
|
|
$talk = [
|
|
|
|
'title' => 'TDD - Test Driven Drupal',
|
|
|
|
'events' => [
|
|
|
|
[
|
|
|
|
'event' => 'drupal_developer_days_2018',
|
|
|
|
'date' => (new DateTime('-1 day'))->getTimestamp(),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event' => 'drupalcamp_london_2019',
|
|
|
|
'date' => (new DateTime('+1 day'))->getTimestamp(),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$eventData = [
|
|
|
|
'drupal_developer_days_2018' => [
|
|
|
|
'name' => 'Drupal Developer Days, Lisbon 2018',
|
|
|
|
],
|
|
|
|
'drupalcamp_london_2019' => [
|
|
|
|
'name' => 'DrupalCamp London 2019',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$events = $this->extension->getEventsForTalk($talk, $eventData);
|
|
|
|
|
|
|
|
$this->assertCount(2, $events);
|
|
|
|
$this->assertSame(
|
|
|
|
['drupal_developer_days_2018', 'drupalcamp_london_2019'],
|
|
|
|
$events->pluck('event')->toArray()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @test */
|
|
|
|
public function events_with_no_date_are_not_returned_for_an_event()
|
|
|
|
{
|
|
|
|
$talk = [
|
|
|
|
'title' => 'TDD - Test Driven Drupal',
|
|
|
|
'events' => [
|
|
|
|
[
|
|
|
|
'event' => 'drupal_developer_days_2018',
|
|
|
|
'date' => (new DateTime('-2 days'))->getTimestamp(),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'event' => 'drupalcamp_london_2019',
|
|
|
|
'date' => '',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$eventData = [
|
|
|
|
'drupal_developer_days_2018' => [
|
|
|
|
'name' => 'Drupal Developer Days, Lisbon 2018',
|
|
|
|
],
|
|
|
|
'drupalcamp_london_2019' => [
|
|
|
|
'name' => 'DrupalCamp London 2019',
|
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
$events = $this->extension->getEventsForTalk($talk, $eventData);
|
|
|
|
|
|
|
|
$this->assertCount(1, $events);
|
|
|
|
$this->assertSame('drupal_developer_days_2018', $events->pluck('event')->first());
|
|
|
|
}
|
2020-01-28 22:34:11 +00:00
|
|
|
|
|
|
|
/** @test */
|
|
|
|
public function specific_event_urls_override_global_urls()
|
|
|
|
{
|
|
|
|
$this->markTestSkipped();
|
|
|
|
}
|
2019-05-20 07:28:28 +00:00
|
|
|
}
|