public function testCanGetLayoutForScheduleWhenDaily()
 {
     $timezone = 'America/New_York';
     $layoutRows[] = array(ColumnNames::BLOCK_START => '02:00:00', ColumnNames::BLOCK_END => '03:00:00', ColumnNames::BLOCK_LABEL => 'PERIOD1', ColumnNames::BLOCK_CODE => PeriodTypes::RESERVABLE, ColumnNames::BLOCK_TIMEZONE => $timezone, ColumnNames::BLOCK_DAY_OF_WEEK => DayOfWeek::SUNDAY);
     $layoutRows[] = array(ColumnNames::BLOCK_START => '03:00:00', ColumnNames::BLOCK_END => '04:00:00', ColumnNames::BLOCK_LABEL => 'PERIOD2', ColumnNames::BLOCK_CODE => PeriodTypes::RESERVABLE, ColumnNames::BLOCK_TIMEZONE => $timezone, ColumnNames::BLOCK_DAY_OF_WEEK => DayOfWeek::SUNDAY);
     $layoutRows[] = array(ColumnNames::BLOCK_START => '04:00:00', ColumnNames::BLOCK_END => '05:00:00', ColumnNames::BLOCK_LABEL => 'PERIOD3', ColumnNames::BLOCK_CODE => PeriodTypes::NONRESERVABLE, ColumnNames::BLOCK_TIMEZONE => $timezone, ColumnNames::BLOCK_DAY_OF_WEEK => DayOfWeek::MONDAY);
     $layoutRows[] = array(ColumnNames::BLOCK_START => '04:00:00', ColumnNames::BLOCK_END => '05:00:00', ColumnNames::BLOCK_LABEL => 'PERIOD3', ColumnNames::BLOCK_CODE => PeriodTypes::NONRESERVABLE, ColumnNames::BLOCK_TIMEZONE => $timezone, ColumnNames::BLOCK_DAY_OF_WEEK => DayOfWeek::TUESDAY);
     $this->db->SetRows($layoutRows);
     $scheduleId = 109;
     $layoutFactory = $this->getMock('ILayoutFactory');
     $expectedLayout = new ScheduleLayout($timezone);
     $layoutFactory->expects($this->once())->method('CreateLayout')->will($this->returnValue($expectedLayout));
     $layout = $this->scheduleRepository->GetLayout($scheduleId, $layoutFactory);
     $this->assertEquals(new GetLayoutCommand($scheduleId), $this->db->_Commands[0]);
     $this->assertTrue($this->db->GetReader(0)->_FreeCalled);
     $sunday = Date::Parse("2013-01-06", $timezone);
     $periods = $layout->GetLayout($sunday);
     $this->assertEquals(2, count($periods));
     $start = $sunday->SetTime(new Time(2, 0, 0));
     $end = $sunday->SetTime(new Time(3, 0, 0));
     $period = new SchedulePeriod($start, $end, 'PERIOD1');
     $this->assertEquals($period, $periods[0]);
     $monday = Date::Parse("2013-01-07", $timezone);
     $periods = $layout->GetLayout($monday);
     $this->assertEquals(1, count($periods));
     $tuesday = Date::Parse("2013-01-08", $timezone);
     $periods = $layout->GetLayout($tuesday);
     $this->assertEquals(1, count($periods));
 }
Esempio n. 2
0
    $resourceId = $resourceRepo->Add($resource);
    $resources[] = $resource;
}
echo "Loaded {$numberOfResources} resources<br/>";
// ACCESSORIES
$db->Execute(new AdHocCommand("delete from accessories where accessory_name like 'load%'"));
$accessoryRepo = new AccessoryRepository();
for ($i = 0; $i < $numberOfAccessories; $i++) {
    $accessory = new Accessory(0, "Load {$i}", 10);
    $id = $accessoryRepo->Add($accessory);
}
echo "Loaded {$numberOfAccessories} accessories<br/>";
// RESERVATIONS
$db->Execute(new AdHocCommand("delete from reservation_series where title like 'load%'"));
$scheduleRepo = new ScheduleRepository();
$layout = $scheduleRepo->GetLayout(1, new ScheduleLayoutFactory('America/Chicago'));
$reservationRepo = new ReservationRepository();
$bookedBy = new UserSession(1);
$bookedBy->Timezone = 'America/Chicago';
$currentDate = Date::Now();
$i = 0;
while ($i < $numberOfReservations) {
    $periods = $layout->GetLayout($currentDate);
    foreach ($periods as $period) {
        $howManyResources = rand(1, count($resources));
        $startResource = rand(0, $howManyResources);
        if ($period->IsReservable()) {
            for ($resourceNum = $startResource; $resourceNum < $howManyResources; $resourceNum++) {
                $userId = getRandomUserId($users)->Id();
                $resource = $resources[$resourceNum];
                $date = new DateRange($period->BeginDate(), $period->EndDate(), 'America/Chicago');