/** * test inserting an organization and regrabbing it from mySQL */ public function testGetValidListingTypeById() { //count the rows in the database $numRows = $this->getConnection()->getRowCount("listingType"); $listingtype = new ListingType(null, $this->VALID_TYPE); $listingtype->insert($this->getPDO()); //grab data from SQL and ensure it matches $pdoListingType = ListingType::getListingTypeById($this->getPDO(), $listingtype->getListingTypeId()); $this->assertSame($numRows + 1, $this->getConnection()->getRowCount("listingType")); $this->assertSame($pdoListingType->getListingTypeInfo(), $this->VALID_TYPE); }
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); } $listingType->delete($pdo); $deletedObject = new stdClass(); $deletedObject->listingTypeId = $id; $reply->message = "Listing type deleted OK"; } } } else { //if not an admin, and attempting a method other than get, throw an exception if (empty($method) === false && $method !== "GET") { throw new RuntimeException("Only administrators are allowed to modify entries", 401); } }