From 8ee32bf309392df87ec8ce63b59057f2b5df17df Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 27 Jun 2016 21:38:13 +0200 Subject: [PATCH] Add a test for the ics. Fixes #28 --- .../Bundle/CalciferBundle/Entity/Event.php | 13 ++++++- .../Tests/Controller/EventControllerTest.php | 36 +++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/Hackspace/Bundle/CalciferBundle/Entity/Event.php b/src/Hackspace/Bundle/CalciferBundle/Entity/Event.php index 3bf1155..9985e33 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Entity/Event.php +++ b/src/Hackspace/Bundle/CalciferBundle/Entity/Event.php @@ -139,7 +139,12 @@ class Event extends BaseEntity $categories[] = $tag->name; } - $uid = sprintf("https://%s/termine/%s",$_SERVER['HTTP_HOST'],$this->slug); + if (array_key_exists('HTTP_HOST',$_SERVER)) { + $uid = sprintf("https://%s/termine/%s",$_SERVER['HTTP_HOST'],$this->slug); + } else { + $uid = sprintf("https://localhost/termine/%s",$this->slug); + } + $event = [ 'SUMMARY' => $this->summary, 'DTSTART' => $this->startdate, @@ -157,6 +162,12 @@ class Event extends BaseEntity $event["GEO"] = [$this->location->lat, $this->location->lon]; } } + if (!array_key_exists('HTTP_HOST',$_SERVER)) { + $dtstamp = new \DateTime(); + $dtstamp->setDate(2016,06,27); + $dtstamp->setTime(0,0,0); + $event['DTSTAMP'] = $dtstamp; + } return $event; } diff --git a/src/Hackspace/Bundle/CalciferBundle/Tests/Controller/EventControllerTest.php b/src/Hackspace/Bundle/CalciferBundle/Tests/Controller/EventControllerTest.php index 7ed7447..848690d 100644 --- a/src/Hackspace/Bundle/CalciferBundle/Tests/Controller/EventControllerTest.php +++ b/src/Hackspace/Bundle/CalciferBundle/Tests/Controller/EventControllerTest.php @@ -100,4 +100,40 @@ class EventControllerTest extends WebTestCase $this->assertTrue($form["location_lon"]->getValue() == $entity->location->lon); } + + public function testICS() { + $this->testPostEventForm(); + + $client = static::makeClient(); + + // events_ics + + $url = $client->getContainer()->get('router')->generate('events_ics'); + + $crawler = $client->request('GET', $url); + $this->assertStatusCode(200, $client); + + $test_doc = <<assertEquals($test_doc, $client->getResponse()->getContent()); + } }