Ejemplo n.º 1
0
 public function testMultiDayEvent()
 {
     $event = new MultiDayEvent();
     $event->setStartDate(new \DateTime('2014-02-01'));
     $event->setExcludeDate(new \DateTime('2014-02-05'));
     $event->setEndDate(new \DateTime('2014-02-07'));
     $this->assertEquals('1 February 2014', $event->getStartDate()->format('j F Y'));
     $this->assertEquals('5 February 2014', $event->getExcludeDate()->format('j F Y'));
     $this->assertEquals('7 February 2014', $event->getEndDate()->format('j F Y'));
 }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
0
 public function testCanAccept_MultiDayClash()
 {
     $event1 = new MultiDayEvent();
     $event1->setStartDate(new \DateTime('2014-02-02'));
     $event1->setEndDate(new \DateTime('2014-02-04'));
     $event1->setStartTime(new \DateTime('14:00'));
     $event1->setEndTime(new \DateTime('15:00'));
     $this->row->addEvent($event1);
     $event2 = new SingleDayEvent();
     $event2->setDate(new \DateTime('2014-02-02'));
     $event2->setStartTime(new \DateTime('14:00'));
     $event2->setEndTime(new \DateTime('15:00'));
     $this->assertFalse($this->row->canAccept($event2));
 }