示例#1
0
 public function testPut()
 {
     $comment = new Comment();
     $comment->setId(50);
     $comment->setContent('Très bien');
     $comment->setPostDate('2012-12-21 00:00:00');
     $comment->setIdUser(1);
     $comment->setIdAnnouncement(10);
     $commentMapper = new CommentMapper();
     $commentMapper->setId(50);
     $commentMapper->updateComment($comment);
     $this->assertEquals($comment, $commentMapper->selectComment());
 }
            Rest::sendResponse(204);
        }
        break;
    case 'delete':
        $commentMapper = new \CommentMapper();
        if ($commentMapper->deleteComment()) {
            Rest::sendResponse(200);
        }
        break;
    case 'put':
        try {
            $comment_ = new Comment();
            $data_comment_ = $http->getRequestVars();
            $commentObject = initObject($data_comment_, $comment_, true);
            if (!emptyObject($commentObject)) {
                $commentMapper = new \CommentMapper();
                if ($commentMapper->updateComment($commentObject)) {
                    Rest::sendResponse(200);
                }
            } else {
                throw new InvalidArgumentException('Need arguments to UPDATE data !');
            }
        } catch (InvalidArgumentException $e) {
            print $e->getComment();
            exit;
        }
        break;
    default:
        Rest::sendResponse(501);
        break;
}