/**
  * Test build repeat events dates without all day
  */
 public function testBuildEventDatesWithoutAllDay()
 {
     $data = ['start' => ['date' => '2016-09-30', 'time' => '10:00:00'], 'end' => ['date' => '2016-09-30', 'time' => '11:00:00'], 'repeat_dates' => ['2016-10-01', '2016-10-02', '2016-10-03']];
     $expected = [['start' => '2016-10-01 10:00:00', 'end' => '2016-10-01 11:00:00'], ['start' => '2016-10-02 10:00:00', 'end' => '2016-10-02 11:00:00'], ['start' => '2016-10-03 10:00:00', 'end' => '2016-10-03 11:00:00']];
     $result = $this->calendarEventsEngine->buildEventDates($data);
     static::assertSame($expected, $result);
 }
 /**
  * Updates an calendar event
  *
  * @param int $id
  * @param array $data
  *
  * @return bool
  */
 public function updateCalendarEvent($id, array $data)
 {
     $eventData = $this->calendarEventsEngine->buildEventData($data);
     $eventDates = $this->calendarEventsEngine->buildEventDates($data);
     $cache = $this->cache;
     $calendarEventRepeatDate = clone $this->calendarEventRepeatDate;
     $calendarEventRepeatDate->where('calendar_event_id', $id)->delete();
     $this->calendarEvent->where('id', $id)->update($eventData);
     $calendarEvent = $this->calendarEvent->where('id', $id)->firstOrFail();
     foreach ($eventDates as $date) {
         $calendarEventRepeatDate = clone $this->calendarEventRepeatDate;
         $calendarEventRepeatDate->start = $date['start'];
         $calendarEventRepeatDate->end = $date['end'];
         $calendarEventRepeatDate->calendarEvent()->associate($calendarEvent);
         $calendarEventRepeatDate->save();
         unset($calendarEventRepeatDate);
     }
     $cache::put(self::CACHE_KEY . $calendarEvent->id, $calendarEvent, $this->cacheTimeToLive);
     $allEvents = $this->getAllEvents();
     $allEvents->put($calendarEvent->id, $calendarEvent);
     $cache::put(self::ALL_EVENTS_KEY, $allEvents, $this->cacheTimeToLive);
     return true;
 }