コード例 #1
0
 private function BuildRepeatOptions($repeatType, $configurationString)
 {
     $configuration = RepeatConfiguration::Create($repeatType, $configurationString);
     $factory = new RepeatOptionsFactory();
     return $factory->Create($repeatType, $configuration->Interval, $configuration->TerminationDate, $configuration->Weekdays, $configuration->MonthlyType);
 }
コード例 #2
0
 public function testFactoryCreatesNoRepeatOptions()
 {
     $factory = new RepeatOptionsFactory();
     $options = $factory->Create('none', 1, null, null, null);
     $this->assertInstanceOf('RepeatNone', $options);
 }
コード例 #3
0
ファイル: Blackout.php プロジェクト: Trideon/gigolo
 /**
  * @param string[] $row
  * @return BlackoutSeries
  */
 public static function FromRow($row)
 {
     $series = new BlackoutSeries($row[ColumnNames::OWNER_USER_ID], $row[ColumnNames::BLACKOUT_TITLE]);
     $series->WithId($row[ColumnNames::BLACKOUT_SERIES_ID]);
     $series->SetCurrentBlackout(new DateRange(Date::FromDatabase($row[ColumnNames::BLACKOUT_START]), Date::FromDatabase($row[ColumnNames::BLACKOUT_END])));
     $series->WithCurrentBlackoutId($row[ColumnNames::BLACKOUT_INSTANCE_ID]);
     $configuration = RepeatConfiguration::Create($row[ColumnNames::REPEAT_TYPE], $row[ColumnNames::REPEAT_OPTIONS]);
     $factory = new RepeatOptionsFactory();
     $options = $factory->Create($row[ColumnNames::REPEAT_TYPE], $configuration->Interval, $configuration->TerminationDate, $configuration->Weekdays, $configuration->MonthlyType);
     $series->WithRepeatOptions($options);
     return $series;
 }
コード例 #4
0
 public function testUpdatesBlackout()
 {
     $startDate = '1/1/2011';
     $endDate = '1/2/2011';
     $startTime = '01:30 PM';
     $endTime = '12:15 AM';
     $timezone = $this->fakeUser->Timezone;
     $dr = DateRange::Create($startDate . ' ' . $startTime, $endDate . ' ' . $endTime, $timezone);
     $title = 'out of service';
     $conflictAction = ReservationConflictResolution::Delete;
     $conflictResolution = ReservationConflictResolution::Create($conflictAction);
     $endDateString = '2012-01-01';
     $repeatType = RepeatType::Daily;
     $repeatInterval = 1;
     $repeatDays = array(1, 2);
     $repeatMonthlyType = RepeatMonthlyType::DayOfMonth;
     $blackoutInstanceId = 1111;
     $scope = SeriesUpdateScope::ThisInstance;
     $roFactory = new RepeatOptionsFactory();
     $repeatEndDate = Date::Parse($endDateString, $timezone);
     $repeatOptions = $roFactory->Create($repeatType, $repeatInterval, $repeatEndDate, $repeatDays, $repeatMonthlyType);
     $this->ExpectPageToReturnCommonBlackoutInfo($startDate, $startTime, $endDate, $endTime, $title, $conflictAction);
     $this->ExpectPageToReturnRepeatInfo($repeatType, $repeatInterval, $endDateString, $repeatDays, $repeatMonthlyType);
     $resourceIds = array(123, 456);
     $this->page->expects($this->once())->method('GetBlackoutResourceIds')->will($this->returnValue($resourceIds));
     $this->page->expects($this->once())->method('GetUpdateBlackoutId')->will($this->returnValue($blackoutInstanceId));
     $this->page->expects($this->once())->method('GetSeriesUpdateScope')->will($this->returnValue($scope));
     $result = $this->getMock('IBlackoutValidationResult');
     $this->blackoutsService->expects($this->once())->method('Update')->with($this->equalTo($blackoutInstanceId), $this->equalTo($dr), $this->equalTo($resourceIds), $this->equalTo($title), $this->equalTo($conflictResolution), $this->equalTo($repeatOptions), $this->equalTo($scope))->will($this->returnValue($result));
     $this->presenter->UpdateBlackout();
 }