コード例 #1
0
ファイル: index.php プロジェクト: davidmancini/jpegery
 $commentImageId = filter_input(INPUT_GET, "commentImageId", FILTER_VALIDATE_INT);
 $commentProfileId = filter_input(INPUT_GET, "commentProfileId", FILTER_VALIDATE_INT);
 $commentDate = filter_input(INPUT_GET, "commentDate", FILTER_SANITIZE_STRING);
 $commentText = filter_input(INPUT_GET, "commentText", FILTER_SANITIZE_STRING);
 if ($method === "GET") {
     //Set an XSRF cookie on 'get' requests
     setXsrfCookie("/");
     //Get the listing based on the current field
     if (empty($commentId) === false) {
         $reply->data = Comment::getCommentByCommentId($pdo, $commentId);
     } elseif (empty($commentImageId) === false) {
         $reply->data = Comment::getCommentByImageId($pdo, $commentImageId)->toArray();
     } elseif (empty($commentProfileId) === false) {
         $reply->data = Comment::getCommentByProfileId($pdo, $commentProfileId)->toArray();
     } elseif (empty($commentText) === false) {
         $reply->data = Comment::getCommentByCommentContent($pdo, $commentText)->toArray();
     }
 }
 //Verify that the object is not empty
 if (empty($_SESSION["profile"]) === false) {
     if ($method === "PUT" || $method === "POST") {
         verifyXsrf();
         $requestContent = file_get_contents("php://input");
         $requestObject = json_decode($requestContent);
         //Ensure that all fields are present.
         if (empty($requestObject->commentImageId) === true) {
             throw new \InvalidArgumentException("Comment Image must exist", 405);
         }
         if (empty($requestObject->commentProfileId) === true) {
             throw new \InvalidArgumentException("Comment Profile must exist", 405);
         }
コード例 #2
0
ファイル: CommentTest.php プロジェクト: davidmancini/jpegery
 /**
  * @expectedException \PDOException
  **/
 public function testGetInvalidCommentByEmptyComment()
 {
     $comments = Comment::getCommentByCommentContent($this->getPDO(), "");
 }