public function testSuperUserDeleteAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     Yii::app()->user->userModel = $super;
     $calendar = CalendarTestHelper::createSavedCalendarByName("My Cal 3", '#66367b');
     //Delete a calendar
     $this->setGetArray(array('id' => $calendar->id));
     $this->resetPostArray();
     $calendars = SavedCalendar::getAll();
     $this->assertEquals(4, count($calendars));
     $this->runControllerWithNoExceptionsAndGetContent('calendars/default/delete');
     $calendars = SavedCalendar::getAll();
     $this->assertEquals(3, count($calendars));
     try {
         SavedCalendar::getById($calendar->id);
         $this->fail();
     } catch (NotFoundException $e) {
         //success
     }
 }
Ejemplo n.º 2
0
 /**
  * @covers CalendarItemsDataProviderFactory::getDataProviderByDateRangeType
  * @covers CalendarItemsDataProvider::fetchData
  * @covers CalendarRowsAndColumnsReportDataProvider::makeSelectQueryAdapter
  * @covers CalendarRowsAndColumnsReportDataProvider::resolveSqlQueryAdapterForCount
  * @covers CalendarRowsAndColumnsReportDataProvider::getData
  */
 public function testGetDataProviderByDateRangeType()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $product = ProductTestHelper::createProductByNameForOwner('Test Product', Yii::app()->user->userModel);
     $savedCalendar = CalendarTestHelper::createSavedCalendarByName('Test Cal', '#315AB0');
     $currentDateTime = new DateTime('NOW');
     $currentDateTime->add(new DateInterval('P1D'));
     $savedCalendarSubscriptions = SavedCalendarSubscriptions::makeByUser(Yii::app()->user->userModel, (string) $savedCalendar->id);
     $dp = CalendarItemsDataProviderFactory::getDataProviderByDateRangeType($savedCalendarSubscriptions, '2014-01-01', $currentDateTime->format('Y-m-d'), SavedCalendar::DATERANGE_TYPE_MONTH);
     $this->assertInstanceOf('CalendarItemsDataProvider', $dp);
     $this->assertEquals('2014-01-01', $dp->getStartDate());
     $this->assertEquals($currentDateTime->format('Y-m-d'), $dp->getEndDate());
     $this->assertEquals(SavedCalendar::DATERANGE_TYPE_MONTH, $dp->getDateRangeType());
     $savedCalendarsData = $dp->getSavedCalendarSubscriptions()->getMySavedCalendarsAndSelected();
     $keys = array_keys($savedCalendarsData);
     $this->assertEquals($savedCalendar->id, $keys[0]);
     $items = CalendarUtil::getFullCalendarItems($dp);
     $this->assertCount(1, $items);
     $this->assertEquals($product->id, $items[0]['modelId']);
 }
Ejemplo n.º 3
0
 public function testSetMySharedCalendarColor()
 {
     $user = User::getByUsername('sam');
     $savedCalendarSubscription = CalendarTestHelper::createSavedCalendarSubscription('Color Cal', null, $user);
     CalendarUtil::setSharedCalendarColor($savedCalendarSubscription);
     $this->assertNotEquals('#66367b', $savedCalendarSubscription->color);
 }