/**
  * Get events for the selected calendars.
  * @param string $selectedMyCalendarIds
  * @param string $selectedSharedCalendarIds
  * @param string $startDate
  * @param string $endDate
  * @param string $dateRangeType
  */
 public function actionGetDayEvents($selectedMyCalendarIds = null, $selectedSharedCalendarIds = null, $startDate = null, $endDate = null, $dateRangeType = null)
 {
     $dataProvider = CalendarUtil::processAndGetDataProviderForEventsData($selectedMyCalendarIds, $selectedSharedCalendarIds, $startDate, $endDate, $dateRangeType, false);
     $items = CalendarUtil::processDataProviderAndGetCalendarItems($dataProvider);
     $modifiedItems = array();
     foreach ($items as $item) {
         $item['start'] = CalendarUtil::getFullCalendarFormattedDateTimeElement($item['start']);
         $startDateTime = strtotime($item['start']);
         if (date('Y-m-d', $startDateTime) == $startDate) {
             $item['end'] = CalendarUtil::getFullCalendarFormattedDateTimeElement($item['end']);
             $modifiedItems[] = $item;
         }
     }
     $modifiedItems = CalendarUtil::populateDetailsUrlForCalendarItems($modifiedItems);
     $calItemListView = new CalendarItemsListView($this->getId(), $this->getModule()->getId(), $modifiedItems, GetUtil::getData());
     Yii::app()->getClientScript()->setToAjaxMode();
     echo $calItemListView->render();
 }
 /**
  * @covers SavedCalendarSubscriptions::makeByUser
  * @covers SavedCalendarSubscriptions::addMySavedCalendars
  * @covers SavedCalendarSubscriptions::addMySubscribedCalendars
  * @covers SavedCalendarSubscriptions::addMySavedCalendar
  * @covers SavedCalendarSubscriptions::addSubscribedToCalendar
  */
 public function testProcessUserCalendarsAndMakeDataProviderForCombinedView()
 {
     $savedCalendars = SavedCalendar::getByName('Test Cal');
     $subscribedCalendars = CalendarUtil::getUserSubscribedCalendars(Yii::app()->user->userModel);
     $dp = CalendarUtil::processAndGetDataProviderForEventsData(strval($savedCalendars[0]->id), strval($subscribedCalendars[0]->savedcalendar->id), null, null, null, false);
     $calendarItems = $dp->getData();
     $this->assertCount(2, $calendarItems);
     $this->assertEquals('First Product', $calendarItems[0]->getTitle());
     $this->assertEquals('Second Product', $calendarItems[1]->getTitle());
     //Check getFullCalendarItems
     $items = CalendarUtil::getFullCalendarItems($dp);
     $this->assertCount(2, $items);
     $this->assertEquals('First Product', $items[0]['title']);
     $this->assertFalse(isset($items[0]['detailsUrl']));
     $this->assertEquals('Second Product', $items[1]['title']);
     $items = CalendarUtil::populateDetailsUrlForCalendarItems($items);
     $this->assertTrue(isset($items[0]['detailsUrl']));
     $this->assertEquals(Yii::app()->createUrl('/products/default/details', array('id' => $savedCalendars[0]->id)), $items[0]['detailsUrl']);
 }