public function testValidatesEachDateThatAReservationRepeatsOn()
 {
     $start = Date::Parse('2010-01-01');
     $end = Date::Parse('2010-01-02');
     $reservationDates = new DateRange($start, $end);
     $twoRepetitions = new RepeatWeekly(1, $start->AddDays(14), array($start->Weekday()));
     $repeatDates = $twoRepetitions->GetDates($reservationDates);
     $reservation = new TestReservationSeries();
     $reservation->WithResource(new FakeBookableResource(1));
     $reservation->WithDuration($reservationDates);
     $reservation->WithRepeatOptions($twoRepetitions);
     $strategy = $this->getMock('IResourceAvailabilityStrategy');
     $strategy->expects($this->exactly(1 + count($repeatDates)))->method('GetItemsBetween')->with($this->anything(), $this->anything())->will($this->returnValue(array()));
     $rule = new ResourceAvailabilityRule($strategy, 'UTC');
     $result = $rule->Validate($reservation);
 }
Ejemplo n.º 2
0
 public function testRepeatWeeklyCreatesRecurranceOnSingleDayEveryIntervalUntilEndAcrossDST()
 {
     $timezone = 'EST';
     $reservationStart = Date::Parse('2010-02-11 08:30', $timezone);
     $reservationEnd = Date::Parse('2010-02-11 10:30', $timezone);
     $duration = new DateRange($reservationStart, $reservationEnd);
     $interval = 1;
     $terminiationDate = Date::Parse('2010-04-01', $timezone);
     $daysOfWeek = array(3);
     $repeatOptions = new RepeatWeekly($interval, $terminiationDate, $daysOfWeek);
     $repeatedDates = $repeatOptions->GetDates($duration);
     $totalDates = 7;
     $firstDate = DateRange::Create('2010-02-17 08:30', '2010-02-17 10:30', $timezone);
     $forthDate = DateRange::Create('2010-03-10 08:30', '2010-03-10 10:30', $timezone);
     $lastDate = DateRange::Create('2010-03-31 08:30', '2010-03-31 10:30', $timezone);
     $this->assertEquals($totalDates, count($repeatedDates));
     $this->assertTrue($firstDate->Equals($repeatedDates[0]), $firstDate->ToString() . ' ' . $repeatedDates[0]->ToString());
     $this->assertTrue($forthDate->Equals($repeatedDates[3]), $forthDate->ToString() . ' ' . $repeatedDates[3]->ToString());
     $this->assertTrue($lastDate->Equals($repeatedDates[$totalDates - 1]), $lastDate->ToString() . ' ' . $repeatedDates[$totalDates - 1]->ToString());
 }