예제 #1
0
 $elevationX = filter_input(INPUT_GET, "segmentStartElevation", FILTER_VALIDATE_INT);
 $elevationY = filter_input(INPUT_GET, "segmentStopElevation", FILTER_VALIDATE_INT);
 //handle all restful calls
 // get some or all segments
 if ($method === "GET") {
     // not sure if i need to set XSRF COOKIE
     // TL; DR: yes
     setXsrfCookie("/");
     if (empty($id) === false) {
         $reply->data = Segment::getSegmentBySegmentId($pdo, $id);
     } elseif (empty($segmentStart) === false) {
         $reply->data = Segment::getSegmentBySegmentStart($pdo, $segmentStart)->toArray();
     } elseif (empty($segmentStop) === false) {
         $reply->data = Segment::getSegmentBySegmentStop($pdo, $segmentStop)->toArray();
     } elseif (empty($elevationX) === false) {
         $reply->data = Segment::getSegmentBySegmentStartElevation($pdo, $elevationX)->toArray();
     } elseif (empty($elevationY) === false) {
         $reply->data = Segment::getSegmentBySegmentStopElevation($pdo, $elevationY)->toArray();
     }
 }
 //if the section belongs to a new an active user allow post, put and delete m
 if (empty($_SESSION["user"]) === false && $_SESSION["user"]->getUserAccountType() !== "X") {
     if ($method === "PUT" || $method === "POST") {
         verifyXsrf();
         $requestContent = file_get_contents("php://input");
         $requestObject = json_decode($requestContent);
         //formatted segments so that the api and class can communicate together
         $segmentStart = new Point($requestObject->segmentStart[0], $requestObject->segmentStart[1]);
         $segmentStop = new Point($requestObject->segmentStop[0], $requestObject->segmentStop[1]);
         // make sure al fields are present, in order to prevent database issues
         if (empty($segmentStart) === true) {
예제 #2
0
 /**
  * test grabbing a segment by SegmentStartElevation that does not exist
  *
  * @expectedException PDOException
  **/
 public function testGetInvalidSegmentByStartElevation()
 {
     //grab a SegmentStartElevation that does not exist
     $segment = Segment::getSegmentBySegmentStartElevation($this->getPDO(), null);
     $this->assertNull($segment);
 }