Exemplo n.º 1
0
     if (empty($requestObject->segmentStartElevation) === true) {
         $requestObject->segmentStartElevation = 0.0;
     }
     if (empty($requestObject->segmentStopElevation) === true) {
         $requestObject->segmentStopElevation = 0.0;
     }
     //preform the a put post or delete
     if ($method === "PUT") {
         //verify the xsrf token
         $segment = Segment::getSegmentBySegmentId($pdo, $id);
         // verify the segment in question exists
         if ($segment === null) {
             throw new RuntimeException("segment must exist", 404);
         }
         $segment = new Segment($id, $segmentStart, $segmentStop, $requestObject->segmentStartElevation, $requestObject->segmentStopElevation);
         $segment->update($pdo);
         $reply->message = "segment update was successful";
     }
     if ($method === "POST") {
         // form a mini-constructor to assemble a segmentStart and a segmentStop....?????
         $segment = new Segment(null, $segmentStart, $segmentStop, $requestObject->segmentStartElevation, $requestObject->segmentStopElevation);
         $segment->insert($pdo);
         $reply->message = "segment insert was successful";
     }
 } elseif ($method === "DELETE") {
     $segment = Segment::getSegmentBySegmentId($pdo, $id);
     if ($segment === null) {
         throw new RuntimeException("segment must exist", 404);
     }
     $segment->delete($pdo);
     $deletedObject = new stdClass();
Exemplo n.º 2
0
 public function testUpdateInvalidSegmentId()
 {
     //create segmentId with non null value and watch it fail
     $segment = new Segment(SegmentTest::INVALID_KEY, $this->VALID_SEGMENTSTART, $this->VALID_SEGMENTSTOP, $this->VALID_SEGMENTSTARTELEVATION, $this->VALID_SEGMENTSTOPELEVATION);
     $segment->update($this->getPDO());
 }