Example #1
0
 public function testCreateEventFromShows()
 {
     $s1 = new Show();
     $s1->setName('Test Show 1');
     $s1->setSlug('test-show-1');
     $p1 = new Performance();
     $p1->setStartDate(new \DateTime('2013-04-01'));
     $p1->setEndDate(new \DateTime('2013-04-02'));
     $p1->setTime(new \DateTime('19:30'));
     $p1->setShow($s1);
     $s1->addPerformance($p1);
     $s2 = new Show();
     $s2->setName('Test Show 2');
     $s2->setSlug('test-show-2');
     $p2 = new Performance();
     $p2->setStartDate(new \DateTime('2013-02-10'));
     $p2->setEndDate(new \DateTime('2013-02-15'));
     $p2->setTime(new \DateTime('19:45'));
     $p2->setShow($s2);
     $s2->addPerformance($p2);
     $p3 = new Performance();
     $p3->setStartDate(new \DateTime('2013-02-15'));
     $p3->setEndDate(new \DateTime('2013-02-15'));
     $p3->setTime(new \DateTime('14:30'));
     $p3->setShow($s2);
     $s2->addPerformance($p3);
     $events = $this->diaryHelper->createEventsFromShows(array($s1, $s2));
     $this->assertEquals(3, count($events));
     $this->assertEquals(new \DateTime('2013-04-01'), $events[0]->getStartDate());
     $this->assertEquals(new \DateTime('2013-02-10'), $events[1]->getStartDate());
     $this->assertEquals(new \DateTime('2013-02-15'), $events[2]->getStartDate());
 }
Example #2
0
 private function generatePerformance(Show $show, \DateTime $start, \DateTime $end)
 {
     $perf = new Performance();
     $perf->setShow($show);
     $perf->setStartDate($start);
     $perf->setEndDate($end);
     $perf->setTime($this->generateTime());
     return $perf;
 }
Example #3
0
 /**
  * Generate an event from a 'performance' of a show (which actually represents a range of performances)
  *
  * @param Show        $show
  * @param Performance $performance
  *
  * @return MultiDayEvent
  */
 public function createEventsFromPerformance(Performance $performance)
 {
     $event = new MultiDayEvent();
     $event->setName($performance->getShow()->getName());
     $event->setLink($this->router->generate('get_show', array('identifier' => $performance->getShow()->getSlug())));
     $event->setStartTime($performance->getTime());
     $event->setVenue($performance->getVenueName());
     $event->setUpdatedAt($performance->getShow()->getTimestamp());
     $event->setUid($performance->getId() . '@camdram.net');
     $event->setDescription($performance->getShow()->getDescription());
     if ($performance->getVenue()) {
         $event->setVenueLink($this->router->generate('get_venue', array('identifier' => $performance->getVenue()->getSlug())));
     }
     if ($performance->getStartDate() < $performance->getExcludeDate() && $performance->getExcludeDate() < $performance->getEndDate()) {
         $end1 = clone $performance->getExcludeDate();
         $end1->modify('-1 day');
         $start2 = clone $performance->getExcludeDate();
         $start2->modify('+1 day');
         $event2 = clone $event;
         $event->setStartDate($performance->getStartDate());
         $event->setEndDate($end1);
         $event2->setStartDate($start2);
         $event2->setEndDate($performance->getEndDate());
         $event2->setUid($performance->getId() . '*****@*****.**');
         return array($event, $event2);
     } else {
         $event->setStartDate($performance->getStartDate());
         $event->setEndDate($performance->getEndDate());
         return array($event);
     }
 }
Example #4
0
 /**
  * @Given /^the show "([^"]*)" starting in (\-?[0-9]+) days? and lasting ([0-9]+) days? at ([0-9]+:[0-9]+)$/
  */
 public function createShowWithDates($show_name, $days, $length, $time)
 {
     $show = $this->createShow($show_name);
     $start_date = $this->getCurrentTime();
     $day_of_week = $start_date->format('N');
     if ($day_of_week < 7) {
         $start_date->modify('-' . $day_of_week . ' days');
     }
     $start_date->modify('+' . $days . ' day');
     $end_date = clone $start_date;
     $end_date->modify('+' . $length . ' days');
     $performance = new Performance();
     $performance->setStartDate($start_date);
     $performance->setEndDate($end_date);
     $performance->setTime(new \DateTime($time));
     $performance->setShow($show);
     $show->addPerformance($performance);
     $this->getEntityManager()->flush();
 }