示例#1
0
 public function testDelete()
 {
     $commentMapper = new CommentMapper();
     $commentMapper->setId(50);
     $commentMapper->deleteComment();
     $this->assertEquals(new Comment(), $commentMapper->selectComment());
 }
         if ($http->getHttpAccept() == 'json') {
             Rest::sendResponse(200, json_encode($commentArray), 'application/json');
         } else {
             if ($http->getHttpAccept() == 'xml') {
                 $options = array('indent' => '     ', 'addDecl' => false, "defaultTagName" => "comment", XML_SERIALIZER_OPTION_RETURN_RESULT => true);
                 $serializer = new XML_Serializer($options);
                 Rest::sendResponse(200, $serializer->serialize($commentArray), 'application/xml');
             }
         }
     } else {
         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 !');