public function testUpdatesReservationAttributeIfTheUserCanEdit()
 {
     $referenceNumber = 'rn';
     $id = 111;
     $value = 'new attribute value';
     $user = $this->fakeUser;
     $resultCollector = new ManageReservationsUpdateAttributeResultCollector();
     $reservation = new ExistingReservationSeries();
     $reservation->UpdateBookedBy($user);
     $reservation->AddAttributeValue(new AttributeValue($id, $value));
     $this->persistenceService->expects($this->once())->method('LoadByReferenceNumber')->with($this->equalTo($referenceNumber))->will($this->returnValue($reservation));
     $this->reservationHandler->expects($this->once())->method('Handle')->with($this->equalTo($reservation), $this->equalTo($resultCollector));
     $result = $this->service->UpdateAttribute($referenceNumber, $id, $value, $user);
 }
 public function testLoadsFilteredResultsAndChecksAuthorizationAgainstPendingReservations()
 {
     $pageNumber = 1;
     $pageSize = 40;
     $groups = array(new UserGroup(1, '1'), new UserGroup(5, '5'), new UserGroup(9, '9'), new UserGroup(22, '22'));
     $myGroups = array(1, 5, 9, 22);
     $this->userRepository->expects($this->once())->method('LoadGroups')->with($this->equalTo($this->fakeUser->UserId), $this->equalTo(RoleLevel::RESOURCE_ADMIN))->will($this->returnValue($groups));
     $filter = new ReservationFilter();
     $expectedFilter = $filter->GetFilter();
     $expectedFilter->_And(new SqlFilterIn(new SqlFilterColumn(TableNames::RESOURCES, ColumnNames::RESOURCE_ADMIN_GROUP_ID), $myGroups));
     $data = new PageableData();
     $this->reservationViewRepository->expects($this->once())->method('GetList')->with($pageNumber, $pageSize, null, null, $expectedFilter)->will($this->returnValue($data));
     $actualData = $this->service->LoadFiltered($pageNumber, $pageSize, $filter, $this->fakeUser);
     $this->assertEquals($data, $actualData);
 }
 /**
  * @param IReservationViewRepository $reservationViewRepository
  * @param IUserRepository $userRepository
  * @param IReservationAuthorization $authorization
  * @param IReservationHandler|null $reservationHandler
  * @param IUpdateReservationPersistenceService|$persistenceService
  */
 public function __construct(IReservationViewRepository $reservationViewRepository, IUserRepository $userRepository, IReservationAuthorization $authorization, $reservationHandler = null, $persistenceService = null)
 {
     parent::__construct($reservationViewRepository, $authorization, $reservationHandler, $persistenceService);
     $this->userRepository = $userRepository;
 }