public function testItemIsNotIncludedIfItStartsAfterLastDisplayedPeriod() { $tz = 'America/Chicago'; $listDate = Date::Parse('2011-02-08', $tz); $layout = new ScheduleLayout($tz); $layout->AppendBlockedPeriod(Time::Parse('0:00', $tz), Time::Parse('2:00', $tz)); $layout->AppendPeriod(Time::Parse('2:00', $tz), Time::Parse('6:00', $tz)); $layout->AppendBlockedPeriod(Time::Parse('6:00', $tz), Time::Parse('0:00', $tz)); $item = new TestBlackoutItemView(1, Date::Parse('2011-02-08 6:00', $tz)->ToUtc(), Date::Parse('2011-02-09 1:00', $tz)->ToUtc(), 1); $r1 = new BlackoutListItem($item); $list = new ScheduleReservationList(array($r1), $layout, $listDate, true); $slots = $list->BuildSlots(); $periods = $layout->GetLayout($listDate, true); $expectedPeriod = $periods[0]; $this->assertEquals(new EmptyReservationSlot($expectedPeriod, $expectedPeriod, $listDate, true), $slots[0]); }
public function testGetsLayoutForEachDayOfWeek() { $utc = 'UTC'; $sunday = Date::Parse('2013-01-06 00:00', $utc); $monday = Date::Parse('2013-01-07 20:00', $utc); $utcDate = $sunday->ToUtc(); $midnight = Time::Parse('00:00', $utc); $time1 = Time::Parse('07:00', $utc); $time2 = Time::Parse('07:45', $utc); $time3 = Time::Parse('08:30', $utc); $time4 = Time::Parse('13:00', $utc); $layout = new ScheduleLayout($utc); $layout->AppendBlockedPeriod($time1, $time2, null, DayOfWeek::SUNDAY); $layout->AppendPeriod($midnight, $time1, null, DayOfWeek::SUNDAY); $layout->AppendPeriod($time2, $time3, 'Period 1', DayOfWeek::SUNDAY); $layout->AppendPeriod($time3, $time4, null, DayOfWeek::SUNDAY); $layout->AppendPeriod($time4, $midnight, 'Period 2', DayOfWeek::SUNDAY); $layout->AppendBlockedPeriod($midnight, $midnight, 'Monday Period', DayOfWeek::MONDAY); $sundayPeriods = $layout->GetLayout($sunday); $mondayPeriods = $layout->GetLayout($monday); $this->assertTrue($layout->UsesDailyLayouts()); $this->assertEquals(5, count($sundayPeriods)); $period1 = new SchedulePeriod($utcDate->SetTime($midnight), $utcDate->SetTime($time1)); $period2 = new NonSchedulePeriod($utcDate->SetTime($time1), $utcDate->SetTime($time2)); $period3 = new SchedulePeriod($utcDate->SetTime($time2), $utcDate->SetTime($time3), 'Period 1'); $period4 = new SchedulePeriod($utcDate->SetTime($time3), $utcDate->SetTime($time4)); $period5 = new SchedulePeriod($utcDate->SetTime($time4), $utcDate->SetTime($midnight, true), 'Period 2'); $this->assertEquals($period1, $sundayPeriods[0], $period1 . ' ' . $sundayPeriods[0]); $this->assertEquals($period2, $sundayPeriods[1], $period2 . ' ' . $sundayPeriods[1]); $this->assertEquals($period3, $sundayPeriods[2]); $this->assertEquals($period4, $sundayPeriods[3]); $this->assertEquals($period5, $sundayPeriods[4]); $this->assertEquals(1, count($mondayPeriods)); $utcDate = $monday->ToUtc(); $period1 = new NonSchedulePeriod($utcDate->SetTime($midnight), $utcDate->SetTime($midnight, true), 'Monday Period'); $this->assertEquals($period1, $mondayPeriods[0], 'Expected ' . $period1 . ' Actual ' . $mondayPeriods[0]); $sundayDailyPeriods = $layout->GetSlots(DayOfWeek::SUNDAY); $mondayDailyPeriods = $layout->GetSlots(DayOfWeek::MONDAY); $this->assertEquals(5, count($sundayDailyPeriods)); $this->assertEquals(new LayoutPeriod($midnight, $time1, PeriodTypes::RESERVABLE, null), $sundayDailyPeriods[0]); $this->assertEquals(1, count($mondayDailyPeriods)); $this->assertEquals(new LayoutPeriod($midnight, $midnight, PeriodTypes::NONRESERVABLE, 'Monday Period'), $mondayDailyPeriods[0]); }