Beispiel #1
0
 /**
  * Initialize route and get response from server
  */
 private function getResponse()
 {
     /*
      * Initialize route from HTTP method
      */
     switch ($this->context->method) {
         /*
          * GET
          */
         case 'HEAD':
         case 'GET':
             $route = new RestoRouteGET($this->context, $this->user);
             break;
             /*
              * POST
              */
         /*
          * POST
          */
         case 'POST':
             $route = new RestoRoutePOST($this->context, $this->user);
             break;
             /*
              * PUT
              */
         /*
          * PUT
          */
         case 'PUT':
             $route = new RestoRoutePUT($this->context, $this->user);
             break;
             /*
              * DELETE
              */
         /*
          * DELETE
          */
         case 'DELETE':
             $route = new RestoRouteDELETE($this->context, $this->user);
             break;
             /*
              * OPTIONS
              */
         /*
          * OPTIONS
          */
         case 'OPTIONS':
             $this->setCORSHeaders();
             return null;
             /*
              * Send an HTTP 404 Not Found
              */
         /*
          * Send an HTTP 404 Not Found
          */
         default:
             RestoLogUtil::httpError(404);
     }
     /*
      * Process route
      */
     $responseObject = $route->route(explode('/', $this->context->path));
     return isset($responseObject) ? $this->format($responseObject) : null;
 }
 public function testDELETE_collection()
 {
     $this->initContext();
     $restoRouteDELETE = new RestoRouteDELETE($this->context, $this->admin);
     $segments = array('collections', 'Landsat');
     $res = $restoRouteDELETE->route($segments);
     $this->assertEquals('success', $res['status']);
 }