public function IsValid() { $key = Configuration::Instance()->GetSectionKey(ConfigSection::ICS, ConfigKeys::ICS_SUBSCRIPTION_KEY); $providedKey = $this->page->GetSubscriptionKey(); if (empty($key) || $providedKey != $key) { Log::Debug('Empty or invalid subscription key. Key provided: %s', $providedKey); return false; } $resourceId = $this->page->GetResourceId(); $scheduleId = $this->page->GetScheduleId(); $userId = $this->page->GetUserId(); if (!empty($resourceId)) { return $this->subscriptionService->GetResource($resourceId)->GetIsCalendarSubscriptionAllowed(); } if (!empty($scheduleId)) { return $this->subscriptionService->GetSchedule($scheduleId)->GetIsCalendarSubscriptionAllowed(); } if (!empty($userId)) { return $this->subscriptionService->GetUser($userId)->GetIsCalendarSubscriptionAllowed(); } return true; }
public function testGetsUserReservationsForTheNextYearByResourceId() { $publicId = '1'; $reservationResult = array(new TestReservationItemView(1, Date::Now(), Date::Now())); $userId = 999; $user = new FakeUser($userId); $weekAgo = Date::Now()->AddDays(-7); $nextYear = Date::Now()->AddDays(365); $this->page->expects($this->once())->method('GetUserId')->will($this->returnValue($publicId)); $this->service->expects($this->once())->method('GetUser')->with($this->equalTo($publicId))->will($this->returnValue($user)); $this->repo->expects($this->once())->method('GetReservationList')->with($this->equalTo($weekAgo), $this->equalTo($nextYear), $this->equalTo($userId), $this->isNull(), $this->isNull(), $this->isNull())->will($this->returnValue($reservationResult)); $this->page->expects($this->once())->method('SetReservations')->with($this->arrayHasKey(0)); $this->presenter->PageLoad(); }
private function StubSubscriptionKey() { $this->page->expects($this->once())->method('GetSubscriptionKey')->will($this->returnValue('123')); $this->fakeConfig->SetSectionKey(ConfigSection::ICS, ConfigKeys::ICS_SUBSCRIPTION_KEY, '123'); }