public function testUpdatesReservationResourceStatuses()
 {
     $resourceStatusId = ResourceStatus::HIDDEN;
     $resourceStatusReasonId = 111;
     $referenceNumber = 'abc123';
     $reservations = array(new TestReservationItemView(1, Date::Now(), Date::Now(), 1), new TestReservationItemView(1, Date::Now(), Date::Now(), 2));
     $pageableReservations = new PageableData($reservations);
     $resource1 = new FakeBookableResource(1);
     $resource1->ChangeStatus(ResourceStatus::AVAILABLE, null);
     $resource2 = new FakeBookableResource(2);
     $resource2->ChangeStatus(ResourceStatus::AVAILABLE, null);
     $this->page->expects($this->once())->method('CanUpdateResourceStatuses')->will($this->returnValue(true));
     $this->page->expects($this->once())->method('GetResourceStatus')->will($this->returnValue($resourceStatusId));
     $this->page->expects($this->once())->method('GetUpdateScope')->will($this->returnValue('all'));
     $this->page->expects($this->once())->method('GetResourceStatusReason')->will($this->returnValue($resourceStatusReasonId));
     $this->page->expects($this->once())->method('GetResourceStatusReferenceNumber')->will($this->returnValue($referenceNumber));
     $this->reservationsService->expects($this->once())->method('LoadFiltered')->with($this->isNull(), $this->isNull(), $this->equalTo(new ReservationFilter(null, null, $referenceNumber, null, null, null, null, null)), $this->equalTo($this->fakeUser))->will($this->returnValue($pageableReservations));
     $this->resourceRepository->expects($this->at(0))->method('LoadById')->with(1)->will($this->returnValue($resource1));
     $this->resourceRepository->expects($this->at(2))->method('LoadById')->with(2)->will($this->returnValue($resource2));
     $this->resourceRepository->expects($this->at(1))->method('Update')->with($this->anything());
     $this->resourceRepository->expects($this->at(3))->method('Update')->with($this->anything());
     $this->presenter->UpdateResourceStatus();
     $this->assertEquals($resourceStatusId, $resource1->GetStatusId());
     $this->assertEquals($resourceStatusReasonId, $resource1->GetStatusReasonId());
 }
예제 #2
0
 public function testChecksStatusOfEachResourceWhenGettingAll()
 {
     $scheduleId = 100;
     $session = $this->fakeUser;
     $user = new FakeUser();
     $user->_IsResourceAdmin = false;
     $resource1 = new FakeBookableResource(1, 'resource1');
     $resource1->ChangeStatus(ResourceStatus::UNAVAILABLE);
     $resources = array($resource1);
     $this->resourceRepository->expects($this->any())->method('GetScheduleResources')->with($this->equalTo($scheduleId))->will($this->returnValue($resources));
     $this->permissionService->expects($this->at(0))->method('CanAccessResource')->with($this->equalTo($resource1), $this->equalTo($session))->will($this->returnValue(true));
     $this->userRepository->expects($this->any())->method('LoadById')->with($this->equalTo($session->UserId))->will($this->returnValue($user));
     $resourceDto1 = new ResourceDto(1, 'resource1', false, $resource1->GetScheduleId(), $resource1->GetMinLength());
     $expected = array($resourceDto1);
     $actualInclusive = $this->resourceService->GetScheduleResources($scheduleId, true, $session);
     $this->assertEquals($expected, $actualInclusive);
     $actualExcluded = $this->resourceService->GetScheduleResources($scheduleId, false, $session);
     $this->assertEquals(array(), $actualExcluded);
 }