コード例 #1
0
ファイル: QuotaTests.php プロジェクト: utn-frm-si/booked
 public function testWhenHourlyLimitIsExceededInYear()
 {
     $duration = new QuotaDurationYear();
     $limit = new QuotaLimitHours(1.5);
     $startDate = Date::Parse('2011-04-03 0:30', $this->schedule->GetTimezone());
     $endDate = Date::Parse('2011-04-03 1:30', $this->schedule->GetTimezone());
     $series = $this->GetHourLongReservation($startDate, $endDate);
     $quota = new Quota(1, $duration, $limit, $series->ResourceId());
     $res1 = new ReservationItemView('ref1', $startDate->SetTimeString('00:00'), $endDate->SetTimeString('00:31'), '', $series->ResourceId(), 98712);
     $res1->ScheduleId = $series->ScheduleId();
     $reservations = array($res1);
     $this->SearchReturns($reservations);
     $exceeds = $quota->ExceedsQuota($series, $this->user, $this->schedule, $this->reservationViewRepository);
     $this->assertTrue($exceeds);
 }
コード例 #2
0
 public function testWhenDeletingAnInstanceItDoesNotCount()
 {
     $ref1 = 'ref1';
     $ref2 = 'ref2';
     $ref3 = 'ref3';
     $duration = new QuotaDurationDay();
     $limit = new QuotaLimitCount(1);
     $quota = new Quota(1, $duration, $limit);
     $r1start = Date::Parse('2011-04-03 1:30', $this->tz);
     $r1End = Date::Parse('2011-04-03 2:30', $this->tz);
     $r2start = Date::Parse('2011-04-04 1:30', $this->tz);
     $r2End = Date::Parse('2011-04-04 2:30', $this->tz);
     $existing1 = new TestReservation($ref1, new DateRange($r1start, $r1End), 1);
     $deleted = new TestReservation($ref2, new DateRange($r2start, $r2End), 2);
     $new = new TestReservation($ref3, new DateRange($r2start, $r2End), 3);
     $builder = new ExistingReservationSeriesBuilder();
     $builder->WithCurrentInstance($existing1)->WithInstance($deleted)->WithInstance($new);
     $series = $builder->BuildTestVersion();
     $series->RemoveInstance($deleted);
     $res1 = new ReservationItemView($ref1, $r1start, $r1End, '', $series->ResourceId(), $existing1->ReservationId());
     $res2 = new ReservationItemView($ref2, $r1start, $r1End, '', $series->ResourceId(), $deleted->ReservationId());
     $res3 = new ReservationItemView($ref3, $r2start, $r2End, '', $series->ResourceId(), $new->ReservationId());
     $reservations = array($res1, $res2, $res3);
     $this->SearchReturns($reservations);
     $exceeds = $quota->ExceedsQuota($series, $this->user, $this->schedule, $this->reservationViewRepository);
     $this->assertFalse($exceeds);
 }