From 24ec20cefa92a2fac1c2f49053a6c12d183bedd6 Mon Sep 17 00:00:00 2001 From: Johannes Wachter Date: Mon, 23 Sep 2019 14:11:13 +0200 Subject: [PATCH] 05 - Add a page template Event overview to the website --- config/templates/pages/event_overview.xml | 57 ++++++++++++++++++ templates/pages/event_overview.html.twig | 26 ++++++++ tests/Functional/Pages/EventOverviewTest.php | 62 ++++++++++++++++++++ 3 files changed, 145 insertions(+) create mode 100644 config/templates/pages/event_overview.xml create mode 100644 templates/pages/event_overview.html.twig create mode 100644 tests/Functional/Pages/EventOverviewTest.php diff --git a/config/templates/pages/event_overview.xml b/config/templates/pages/event_overview.xml new file mode 100644 index 0000000..e386244 --- /dev/null +++ b/config/templates/pages/event_overview.xml @@ -0,0 +1,57 @@ + + diff --git a/templates/pages/event_overview.html.twig b/templates/pages/event_overview.html.twig new file mode 100644 index 0000000..7ef4d3c --- /dev/null +++ b/templates/pages/event_overview.html.twig @@ -0,0 +1,26 @@ +{% extends "base.html.twig" %} + +{% block content %} +
+
+

{{ content.title }}

+

{{ content.article|raw }}

+
+
+ +
+
+ {% for event in content.events %} +
+

{{ event.resource.title }}

+

{{ event.resource.teaser }}

+

+ + View details » + +

+
+ {% endfor %} +
+
+{% endblock %} diff --git a/tests/Functional/Pages/EventOverviewTest.php b/tests/Functional/Pages/EventOverviewTest.php new file mode 100644 index 0000000..c56e157 --- /dev/null +++ b/tests/Functional/Pages/EventOverviewTest.php @@ -0,0 +1,62 @@ +client = $this->createWebsiteClient(); + $this->initPhpcr(); + } + + public function testEventOverview(): void + { + $event1 = $this->createEvent('Sulu is awesome', 'en'); + $this->enableEvent($event1); + $event2 = $this->createEvent('Symfony Live is awesome', 'en'); + $this->enableEvent($event2); + $event3 = $this->createEvent('Disabled', 'en'); + + $this->createPage( + 'event_overview', + 'example', + [ + 'title' => 'Symfony Live', + 'url' => '/events', + 'published' => true, + ], + ); + + $crawler = $this->client->request(Request::METHOD_GET, '/en/events'); + + $response = $this->client->getResponse(); + $this->assertInstanceOf(Response::class, $response); + $this->assertResponseIsSuccessful(); + $this->assertStringContainsString('Symfony Live', $crawler->filter('h1')->html()); + $this->assertNotNull($content = $crawler->filter('.event-title')->eq(0)->html()); + $this->assertStringContainsString($event1->getTitle() ?: '', $content); + $this->assertNotNull($content = $crawler->filter('.event-title')->eq(1)->html()); + $this->assertStringContainsString($event2->getTitle() ?: '', $content); + } + + protected static function getDocumentManager(): DocumentManagerInterface + { + return static::getContainer()->get('sulu_document_manager.document_manager'); + } +}