示例#1
0
 /**
  * Test Protocol Comment embed Document
  */
 public function testProtocolComment()
 {
     $protocolComment = new ProtocolComment();
     $protocolComment->setBody('test');
     $this->documentManager->persist($protocolComment);
     $this->documentManager->flush();
     $this->assertNotEmpty($protocolComment->getId());
     $this->assertNotEmpty($protocolComment->getCreatedAt());
     $this->assertNotEmpty($protocolComment->getBody());
     $this->documentManager->remove($protocolComment);
     $this->documentManager->flush();
 }
 /**
  * @param Request $request
  * @param $protocolId
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function patchAddCommentAction(Request $request, $protocolId)
 {
     $dm = $this->get('doctrine_mongodb')->getManager();
     $protocol = $this->getProtocol($protocolId);
     $comment = new ProtocolComment();
     $comment->setBody($request->get('body'));
     $protocol->addComment($comment);
     $dm->persist($protocol);
     $dm->flush();
     $dm->clear();
     return $this->getProtocol($protocolId)->getComment()->toArray();
 }