public function testBindsDatesWhenResourceHasMinimumTime() { $timezone = 'UTC'; $scheduleId = 1; $dateString = Date::Now()->AddDays(1)->SetTimeString('02:55:22')->Format('Y-m-d H:i:s'); $endDateString = Date::Now()->AddDays(1)->SetTimeString('4:55:22')->Format('Y-m-d H:i:s'); $dateInUserTimezone = Date::Parse($dateString, $timezone); $startDate = Date::Parse($dateString, $timezone); $endDate = Date::Parse($endDateString, $timezone); $expectedEndDate = $startDate->AddHours(2); $resourceDto = new ResourceDto(1, 'resource', true, $scheduleId, TimeInterval::FromHours(2)); $this->initializer->expects($this->any())->method('CurrentUser')->will($this->returnValue($this->fakeUser)); $this->initializer->expects($this->any())->method('GetTimezone')->will($this->returnValue($timezone)); $this->initializer->expects($this->any())->method('GetReservationDate')->will($this->returnValue($dateInUserTimezone)); $this->initializer->expects($this->any())->method('GetStartDate')->will($this->returnValue($startDate)); $this->initializer->expects($this->any())->method('GetEndDate')->will($this->returnValue($endDate)); $this->initializer->expects($this->any())->method('GetScheduleId')->will($this->returnValue($scheduleId)); $this->initializer->expects($this->any())->method('PrimaryResource')->will($this->returnValue($resourceDto)); $startPeriods = array(new SchedulePeriod(Date::Now(), Date::Now())); $endPeriods = array(new SchedulePeriod(Date::Now()->AddDays(1), Date::Now()->AddDays(1))); $layout = $this->getMock('IScheduleLayout'); $this->scheduleRepository->expects($this->once())->method('GetLayout')->with($this->equalTo($scheduleId), $this->equalTo(new ReservationLayoutFactory($timezone)))->will($this->returnValue($layout)); $layout->expects($this->at(0))->method('GetLayout')->with($this->equalTo($startDate))->will($this->returnValue($startPeriods)); $layout->expects($this->at(1))->method('GetLayout')->with($this->equalTo($endDate))->will($this->returnValue($endPeriods)); $this->initializer->expects($this->once())->method('SetDates')->with($this->equalTo($startDate), $this->equalTo($expectedEndDate), $this->equalTo($startPeriods), $this->equalTo($endPeriods)); $this->initializer->expects($this->once())->method('HideRecurrence')->with($this->equalTo(false)); $this->initializer->expects($this->once())->method('IsNew')->will($this->returnValue(true)); $binder = new ReservationDateBinder($this->scheduleRepository); $binder->Bind($this->initializer); }