コード例 #1
0
 public function testSuperUserAllDefaultControllerActions()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->runControllerWithRedirectExceptionAndGetContent('calendars/default/details');
     $this->runControllerWithNoExceptionsAndGetContent('calendars/default/combinedDetails');
     //Default Controller actions requiring some sort of parameter via POST or GET
     //Load Model Edit Views
     $calendars = SavedCalendar::getAll();
     $this->assertEquals(2, count($calendars));
     $superCalId = self::getModelIdByModelNameAndName('SavedCalendar', 'My Cal 1');
     $superCalId2 = self::getModelIdByModelNameAndName('SavedCalendar', 'My Cal 2');
     $this->setGetArray(array('id' => $superCalId));
     $this->runControllerWithNoExceptionsAndGetContent('calendars/default/edit');
     //Save Calendar
     SavedCalendar::getById($superCalId);
     $this->setPostArray(array('SavedCalendar' => array('name' => 'My New Cal 1')));
     //Test having a failed validation on the saved calendar during save.
     $this->setGetArray(array('id' => $superCalId));
     $this->setPostArray(array('SavedCalendar' => array('name' => ''), 'ajax' => 'edit-form', 'RowsAndColumnsReportWizardForm' => array('filtersStructure' => '', 'Filters' => array(array('attributeIndexOrDerivedType' => 'createdDateTime', 'structurePosition' => '1', 'valueType' => 'After', 'value' => '2/18/2014', 'availableAtRunTime' => '0')))));
     $content = $this->runControllerWithExitExceptionAndGetContent('calendars/default/edit');
     $this->assertContains('Name cannot be blank', $content);
     //Filter validation
     $this->setGetArray(array('id' => $superCalId));
     $this->setPostArray(array('SavedCalendar' => array('name' => 'Test'), 'ajax' => 'edit-form', 'RowsAndColumnsReportWizardForm' => array('filtersStructure' => '1', 'Filters' => array(array('attributeIndexOrDerivedType' => 'createdDateTime', 'structurePosition' => '1', 'valueType' => 'After', 'value' => '', 'availableAtRunTime' => '0')))));
     $content = $this->runControllerWithExitExceptionAndGetContent('calendars/default/edit');
     $this->assertContains('Value cannot be blank', $content);
     //Valid case
     $this->setGetArray(array('id' => $superCalId));
     $this->setPostArray(array('SavedCalendar' => array('name' => 'My New Cal 1'), 'ajax' => 'edit-form', 'RowsAndColumnsReportWizardForm' => array('filtersStructure' => '1', 'Filters' => array(array('attributeIndexOrDerivedType' => 'createdDateTime', 'structurePosition' => '1', 'valueType' => 'After', 'value' => '2/18/2014', 'availableAtRunTime' => '0')))));
     $this->runControllerWithExitExceptionAndGetContent('calendars/default/edit');
     //Load Model Detail Views
     $this->resetPostArray();
     $this->runControllerWithRedirectExceptionAndGetContent('calendars/default/details');
     $this->resetGetArray();
     $this->runControllerWithNoExceptionsAndGetContent('calendars/default/modalList');
     //Month view
     $this->setGetArray(array('selectedMyCalendarIds' => $superCalId . ',' . $superCalId2, 'selectedSharedCalendarIds' => null, 'startDate' => CalendarUtil::getStartDate(SavedCalendar::DATERANGE_TYPE_MONTH), 'endDate' => CalendarUtil::getEndDate(SavedCalendar::DATERANGE_TYPE_MONTH), 'dateRangeType' => SavedCalendar::DATERANGE_TYPE_MONTH));
     $content = $this->runControllerWithNoExceptionsAndGetContent('calendars/default/getEvents');
     $this->assertContains('My First Prod', $content);
     //Week view
     $this->setGetArray(array('selectedMyCalendarIds' => $superCalId . ',' . $superCalId2, 'selectedSharedCalendarIds' => null, 'startDate' => CalendarUtil::getStartDate(SavedCalendar::DATERANGE_TYPE_WEEK), 'endDate' => CalendarUtil::getEndDate(SavedCalendar::DATERANGE_TYPE_WEEK), 'dateRangeType' => SavedCalendar::DATERANGE_TYPE_WEEK));
     $content = $this->runControllerWithNoExceptionsAndGetContent('calendars/default/getEvents');
     $this->assertContains('My First Prod', $content);
     //Day view
     $this->setGetArray(array('selectedMyCalendarIds' => $superCalId . ',' . $superCalId2, 'selectedSharedCalendarIds' => null, 'startDate' => CalendarUtil::getStartDate(SavedCalendar::DATERANGE_TYPE_DAY), 'endDate' => CalendarUtil::getEndDate(SavedCalendar::DATERANGE_TYPE_DAY), 'dateRangeType' => SavedCalendar::DATERANGE_TYPE_DAY));
     $this->runControllerWithNoExceptionsAndGetContent('calendars/default/getEvents');
     $this->runControllerWithNoExceptionsAndGetContent('calendars/default/getDayEvents');
     $this->setGetArray(array('modelClass' => 'Product', 'modelId' => $superCalId));
     $this->runControllerWithNoExceptionsAndGetContent('calendars/default/getCalendarItemDetail');
     //Add subscribed calendar
     $user = UserTestHelper::createBasicUser('jim');
     $subscribedCalendar = CalendarTestHelper::createSavedCalendarByName("My Subscribed Cal", '#315AB0');
     $subscribedCalendar->owner = $user;
     $subscribedCalendar->save();
     $this->setGetArray(array('id' => $subscribedCalendar->id));
     $content = $this->runControllerWithNoExceptionsAndGetContent('calendars/default/addSubsriptionForCalendar');
     $this->assertContains('My Subscribed Cal', $content);
     $subscribedCalendars = CalendarUtil::getUserSubscribedCalendars($super);
     $this->setGetArray(array('id' => $subscribedCalendars[0]->id));
     $content = $this->runControllerWithNoExceptionsAndGetContent('calendars/default/unsubscribe');
     $this->assertNotContains('My Subscribed Cal', $content);
 }
コード例 #2
0
 /**
  * Add my subscribed calendars.
  * @param SavedCalendarSubscriptions $savedCalendarSubscriptions
  * @param User $user
  * @param string $subscribedCalendarIds
  * @return \SavedCalendarSubscriptions
  */
 private static function addMySubscribedCalendars(SavedCalendarSubscriptions $savedCalendarSubscriptions, User $user, $subscribedCalendarIds)
 {
     $mySubscribedCalendars = CalendarUtil::getUserSubscribedCalendars($user);
     if (count($mySubscribedCalendars) > 0) {
         ZurmoConfigurationUtil::setByUserAndModuleName($user, 'CalendarsModule', 'mySubscribedCalendarSelections', $subscribedCalendarIds);
         $subscribedCalendarIdArray = array();
         if ($subscribedCalendarIds != null) {
             $subscribedCalendarIdArray = explode(',', $subscribedCalendarIds);
             // Not Coding Standard
         }
         foreach ($mySubscribedCalendars as $key => $mySubscribedCalendar) {
             CalendarUtil::setSharedCalendarColor($mySubscribedCalendar);
             if (in_array($mySubscribedCalendar->id, $subscribedCalendarIdArray)) {
                 $savedCalendarSubscriptions->addSubscribedToCalendar($mySubscribedCalendar, true);
             } else {
                 $savedCalendarSubscriptions->addSubscribedToCalendar($mySubscribedCalendar, false);
             }
         }
     }
 }
コード例 #3
0
 /**
  * @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']);
 }