Esempio n. 1
0
 public function testCreate()
 {
     $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->insertComment($comment);
     $commentMapper->setId(50);
     $this->assertEquals($comment, $commentMapper->selectComment());
 }
                    $options = array('indent' => '     ', 'addDecl' => false, XML_SERIALIZER_OPTION_RETURN_RESULT => true, "defaultTagName" => "comment");
                    $serializer = new XML_Serializer($options);
                    Rest::sendResponse(200, $serializer->serialize($commentsArray), 'application/xml');
                }
            }
        } else {
            Rest::sendResponse(204);
        }
        break;
    case 'post':
        try {
            $comment = new Comment();
            $data_comment = $http->getRequestVars();
            $commentObject = initObject($data_comment, $comment, true);
            if (!emptyObject($commentObject)) {
                $commentMapper = new CommentMapper();
                if ($commentMapper->insertComment($commentObject)) {
                    Rest::sendResponse(200);
                }
            } else {
                throw new InvalidArgumentException('Need arguments to POST data !');
            }
        } catch (InvalidArgumentException $e) {
            $e->getComment();
            exit;
        }
        break;
    default:
        Rest::sendResponse(501);
        break;
}