public function testRepeatDailyCreatesRecurranceEverySpecifiedDayUntilEndAcrossDST() { $reservationStart = Date::Parse('2010-02-12 08:30', 'CST'); $reservationEnd = Date::Parse('2010-02-12 10:30', 'CST'); $duration = new DateRange($reservationStart, $reservationEnd); $interval = 2; $terminiationDate = Date::Parse('2010-04-02', 'CST'); $repeatOptions = new RepeatDaily($interval, $terminiationDate); $repeatedDates = $repeatOptions->GetDates($duration); $totalDates = 8 + 15 + 1; $firstDate = DateRange::Create('2010-02-14 08:30', '2010-02-14 10:30', 'CST'); $lastDate = DateRange::Create('2010-04-01 08:30', '2010-04-01 10:30', 'CST'); $this->assertEquals($totalDates, count($repeatedDates)); $this->assertTrue($firstDate->Equals($repeatedDates[0]), $firstDate->ToString() . ' ' . $repeatedDates[0]->ToString()); $this->assertTrue($lastDate->Equals($repeatedDates[$totalDates - 1]), $lastDate->ToString() . ' ' . $repeatedDates[$totalDates - 1]->ToString()); }
public function testChecksAndCreatesForEachRecurringDate() { $userId = $this->fakeUser->UserId; $start = Date::Parse('2011-01-01 01:01:01'); $end = Date::Parse('2011-01-01 02:02:02'); $range = new DateRange($start, $end); $resourceId = 1; $resourceIds = array($resourceId); $title = 'title'; $repeatEnd = $start->AddDays(3); $repeatDaily = new RepeatDaily(1, $repeatEnd); $repeatDates = $repeatDaily->GetDates($range); /** @var $allDates DateRange[] */ $allDates = array_merge(array($range), $repeatDates); $series = BlackoutSeries::Create($userId, $title, $range); $series->Repeats($repeatDaily); $series->AddResourceId($resourceId); foreach ($repeatDates as $date) { $series->AddBlackout(new Blackout($date)); } for ($i = 0; $i < count($allDates); $i++) { $date = $allDates[$i]; $this->reservationViewRepository->expects($this->at($i))->method('GetBlackoutsWithin')->with($this->equalTo($date))->will($this->returnValue(array())); $this->reservationViewRepository->expects($this->at($i + count($allDates)))->method('GetReservationList')->with($this->equalTo($date->GetBegin()), $this->equalTo($date->GetEnd()))->will($this->returnValue(array())); } $this->blackoutRepository->expects($this->at(0))->method('Add')->with($this->equalTo($series)); $this->assertEquals(4, $i, 'should create 4 blackouts'); $result = $this->service->Add($range, $resourceIds, $title, $this->conflictHandler, $repeatDaily); $this->assertTrue($result->WasSuccessful()); }