/** * 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); }
/** * @expectedException InvalidArgumentException */ public function testAuthorFailWithObject() { $p = new Post(); $o = new \stdClass(); // Yes we know this will go wrong. /** @noinspection PhpParamsInspection */ $p->setAuthor($o); }