Example #1
0
 /**
  * Writes a new Post
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function newAction(Request $request)
 {
     $this->denyAccessUnlessGranted('ROLE_AUTHOR');
     $post = new Post();
     $post->setAuthor($this->getUser());
     return $this->handlePost($request, $post);
 }
Example #2
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testAuthorFailWithObject()
 {
     $p = new Post();
     $o = new \stdClass();
     // Yes we know this will go wrong.
     /** @noinspection PhpParamsInspection */
     $p->setAuthor($o);
 }