public function testLoadsResourceByPublicId() { $publicId = uniqid(); $fr = new FakeResourceAccess(); $rows = $fr->GetRows(); $this->db->SetRow(0, $rows); $car = new CustomAttributeValueRow(); $car->With(1, 'value')->With(2, 'value2'); $this->db->SetRow(1, $car->Rows()); $loadResourceCommand = new GetResourceByPublicIdCommand($publicId); $attributes = new GetAttributeValuesCommand(1, CustomAttributeCategory::RESOURCE); $resource = $this->repository->LoadByPublicId($publicId); $this->assertTrue($this->db->ContainsCommand($loadResourceCommand)); $this->assertTrue($this->db->ContainsCommand($attributes)); $this->assertNotNull($resource); $this->assertEquals('value', $resource->GetAttributeValue(1)); $this->assertEquals('value2', $resource->GetAttributeValue(2)); }
return; } $user_session = new UserSession($user->Id()); // load resource by contact_info or rid $resourceRepository = new ResourceRepository(); $contact_info = trim($_REQUEST['contact_info']); $rid = trim($_REQUEST['rid']); if ($contact_info && $rid) { header('HTTP/1.1 406 Not Acceptable', true, 406); print json_encode(array('message' => "You must not set both contact_info and rid")); return; } if ($contact_info) { $resource = $resourceRepository->LoadByContactInfo($contact_info); } elseif ($rid) { $resource = $resourceRepository->LoadByPublicId($rid); } $updateAction = ReservationAction::Update; $persistenceFactory = new ReservationPersistenceFactory(); $persistenceService = $persistenceFactory->Create($updateAction); $handler = ReservationHandler::Create($updateAction, $persistenceService, ServiceLocator::GetServer()->GetUserSession()); $reservationRepository = new ReservationRepository(); $series = $reservationRepository->LoadByReferenceNumber($params['rn']); if (!$series) { header('HTTP/1.1 404 Not Found', true, 404); $response = array('reference_number' => $rn, 'message' => 'Reservation could not be found'); print json_encode($response); return; } $series->ApplyChangesTo(SeriesUpdateScope::FullSeries); if ($params['starts_at'] || $params['ends_at']) {