public function testIsNotValidWhenTurnedOffForSchedule()
 {
     $schedule = new FakeSchedule(12);
     $schedule->DisableSubscription();
     $publicId = uniqid();
     $this->page->expects($this->once())->method('GetScheduleId')->will($this->returnValue($publicId));
     $this->subscriptionService->expects($this->once())->method('GetSchedule')->with($this->equalTo($publicId))->will($this->returnValue($schedule));
     $this->StubSubscriptionKey();
     $isValid = $this->validator->IsValid();
     $this->assertFalse($isValid);
 }
 public function testDoesNotUpdateScheduleIfUserDoesNotHaveAccess()
 {
     $user = $this->getMock('User');
     $this->userRepository->expects($this->once())->method('LoadById')->with($this->equalTo($this->fakeUser->UserId))->will($this->returnValue($user));
     $schedule = new FakeSchedule(1);
     $schedule->SetAdminGroupId(2);
     $user->expects($this->at(0))->method('IsScheduleAdminFor')->with($this->equalTo($schedule))->will($this->returnValue(false));
     $actualEx = null;
     try {
         $this->repo->Update($schedule);
     } catch (Exception $ex) {
         $actualEx = $ex;
     }
     $this->assertNotEmpty($actualEx, "should have thrown an exception");
 }
Пример #3
0
 public function testWhenUserIsInAdminGroupForSchedule()
 {
     $scheduleId = 123;
     $adminGroupId = 223;
     $schedule = new FakeSchedule($scheduleId);
     $schedule->SetAdminGroupId($adminGroupId);
     $adminUser = new User();
     $regularUser = new User();
     $adminGroup = new UserGroup($adminGroupId, 'admin', null, RoleLevel::SCHEDULE_ADMIN);
     $group1 = new UserGroup(1, 'random group');
     $group2 = new UserGroup(2, 'group with admin');
     $adminUserGroups = array($group1, $adminGroup);
     $userGroups = array($group1, $group2);
     $adminUser->WithGroups($adminUserGroups);
     $regularUser->WithGroups($userGroups);
     $this->assertTrue($adminUser->IsScheduleAdminFor($schedule));
     $this->assertFalse($regularUser->IsScheduleAdminFor($schedule));
 }