Пример #1
0
 function it_gets_a_json_string(SerializerInterface $serializer, CalendarAdapterInterface $adapter)
 {
     $startDate = new \DateTime();
     $endDate = new \Datetime();
     $events = [];
     $json = '{}';
     $adapter->getData($startDate, $endDate)->shouldBeCalled()->willReturn($events);
     $serializer->serialize($events)->shouldBeCalled()->willReturn($json);
     $this->getData($startDate, $endDate)->shouldReturn($json);
 }
Пример #2
0
 function it_gets_a_json_string(SerializerInterface $serializer, EventDispatcherInterface $dispatcher, CalendarEvent $calendarEvent, EventInterface $event)
 {
     $startDate = new \DateTime();
     $endDate = new \DateTime();
     $events = [$event];
     $json = '{ [events: foo] }';
     $dispatcher->dispatch(CalendarEvent::SET_DATA, Argument::type('AncaRebeca\\FullCalendarBundle\\Event\\CalendarEvent'))->shouldBeCalled()->willReturn($calendarEvent);
     $calendarEvent->getEvents()->shouldBeCalled()->willReturn($events);
     $serializer->serialize($events)->shouldBeCalled()->willReturn($json);
     $this->getData($startDate, $endDate, [])->shouldReturn($json);
 }
Пример #3
0
 /**
  * @param \Datetime $startDate
  * @param \DateTime $endDate
  *
  * @return string json
  */
 public function getData(\Datetime $startDate, \DateTime $endDate)
 {
     $events = $this->adapter->getData($startDate, $endDate);
     return $this->serializer->serialize($events);
 }
Пример #4
0
 /**
  * @param \Datetime $startDate
  * @param \DateTime $endDate
  * @param array $filters
  *
  * @return string json
  */
 public function getData(\Datetime $startDate, \DateTime $endDate, array $filters = [])
 {
     /** @var CalendarEvent $event */
     $event = $this->dispatcher->dispatch(CalendarEvent::SET_DATA, new CalendarEvent($startDate, $endDate, $filters));
     return $this->serializer->serialize($event->getEvents());
 }