public function testWhenScheduleIdIsProvided() { $scheduleId = 12346; $this->server->SetQueryString(WebServiceQueryStringKeys::SCHEDULE_ID, $scheduleId); $this->reservationViewRepository->expects($this->once())->method('GetReservationList')->with($this->equalTo($this->defaultStartDate), $this->equalTo($this->defaultEndDate), $this->isNull(), $this->isNull(), $this->equalTo($scheduleId), $this->isNull())->will($this->returnValue(array())); $this->service->GetReservations(); }
public function testDeletesExistingReservation() { $referenceNumber = '12323'; $updateScope = SeriesUpdateScope::FullSeries; $this->server->SetQueryString(WebServiceQueryStringKeys::UPDATE_SCOPE, $updateScope); $controllerResult = new ReservationControllerResult($referenceNumber); $this->controller->expects($this->once())->method('Delete')->with($this->equalTo($this->server->GetSession()), $this->equalTo($referenceNumber), $this->equalTo($updateScope))->will($this->returnValue($controllerResult)); $this->service->Delete($referenceNumber); $expectedResponse = new DeletedResponse($this->server, $referenceNumber); $this->assertEquals($expectedResponse, $this->server->_LastResponse); $this->assertEquals(RestResponse::OK_CODE, $this->server->_LastResponseCode); }
public function testGetsAllUsers() { $userId = 123232; $userItemView = new UserItemView(); $userItemView->Id = $userId; $userItemView->DateCreated = Date::Now(); $userItemView->LastLogin = Date::Now(); $userList = array($userItemView); $users = new PageableData($userList); $attributes = array(new FakeCustomAttribute(1), new FakeCustomAttribute(2)); $username = '******'; $position = 'position'; $att1 = 'att1'; $this->server->SetQueryString(WebServiceQueryStringKeys::USERNAME, $username); $this->server->SetQueryString(WebServiceQueryStringKeys::POSITION, $position); $this->server->SetQueryString('att1', $att1); $expectedFilter = new UserFilter($username, null, null, null, null, null, $position, array(new Attribute($attributes[0], $att1))); $this->userRepositoryFactory->expects($this->once())->method('Create')->with($this->equalTo($this->server->GetSession()))->will($this->returnValue($this->userRepository)); $this->userRepository->expects($this->once())->method('GetList')->with($this->isNull(), $this->isNull(), $this->isNull(), $this->isNull(), $expectedFilter->GetFilter(), AccountStatus::ACTIVE)->will($this->returnValue($users)); $this->attributeService->expects($this->once())->method('GetByCategory')->with($this->equalTo(CustomAttributeCategory::USER))->will($this->returnValue($attributes)); $expectedResponse = new UsersResponse($this->server, $userList, array(1 => 'fakeCustomAttribute1', 2 => 'fakeCustomAttribute2')); $this->service->GetUsers(); $this->assertEquals($expectedResponse, $this->server->_LastResponse); }
public function testGetsSingleResourceAvailabilityForARequestTime() { $date = Date::Parse('2014-01-01 04:30:00', 'America/Chicago'); $this->server->SetQueryString(WebServiceQueryStringKeys::DATE_TIME, $date->ToIso()); $resourceId1 = 1; $startTime = $date->AddHours(-1); $endTime = $date->AddHours(1); $resource = new FakeBookableResource($resourceId1); $this->repository->expects($this->once())->method('LoadById')->with($this->equalTo($resourceId1))->will($this->returnValue($resource)); $conflicting = new TestReservationItemView(1, $startTime, $endTime, $resourceId1); $upcoming = new TestReservationItemView(2, $endTime, $endTime->AddHours(3), $resourceId1); $upcoming2 = new TestReservationItemView(3, $endTime->AddHours(3), $endTime->AddHours(4), $resourceId1); $upcoming3 = new TestReservationItemView(4, $endTime->AddHours(5), $endTime->AddHours(6), $resourceId1); $reservations = array($conflicting, $upcoming, $upcoming2, $upcoming3); $endDate = $date->AddDays(7); $this->reservationRepository->expects($this->once())->method('GetReservationList')->with($this->equalTo($date->AddDays(-1)->ToUtc()), $this->equalTo($endDate->ToUtc()), $this->isEmpty(), $this->isEmpty(), $this->isEmpty(), $this->equalTo($resourceId1))->will($this->returnValue($reservations)); $this->service->GetAvailability($resourceId1); $resources = array(new ResourceAvailabilityResponse($this->server, $resource, $conflicting, $upcoming, $endTime->AddHours(4), $endDate)); $this->assertEquals(new ResourcesAvailabilityResponse($this->server, $resources), $this->server->_LastResponse); }