예제 #1
0
 /**
  * test updating a listing type that does not exist
  *
  * @expectedException PDOException
  */
 public function testUpdateInvalidListingType()
 {
     //create a listing type and update without inserting it
     $listingtype = new ListingType(null, $this->VALID_TYPE);
     $listingtype->update($this->getPDO());
 }
예제 #2
0
 if ($method === "PUT" || $method === "POST") {
     //verifyXsrf();
     $requestContent = file_get_contents("php://input");
     $requestObject = json_decode($requestContent);
     //make sure all fields are present, in order to prevent database issues
     if (empty($requestObject->listingType) === true) {
         throw new InvalidArgumentException("listing type info cannot be empty", 405);
     }
     //perform the actual put or post
     if ($method === "PUT") {
         $listingType = ListingType::getListingTypeById($pdo, $id);
         if ($listingType === null) {
             throw new RuntimeException("Listing type does not exist", 404);
         }
         $listingType = new ListingType($id, $requestObject->listingType);
         $listingType->update($pdo);
         $reply->message = "Listing type updated OK";
     } else {
         if ($method === "POST") {
             $listingType = new ListingType(null, $requestObject->listingType);
             $listingType->insert($pdo);
             $reply->message = "Listing type created OK";
         }
     }
 } else {
     if ($method === "DELETE") {
         //verifyXsrf();
         $listingType = ListingType::getListingTypeById($pdo, $id);
         if ($listingType === null) {
             throw new RuntimeException("Listing type does not exist", 404);
         }