/** * @Route("/") * @Method("post") */ public function indexPostAction(Request $request) { $form = $this->form_factory->create('blog_article'); $form->handleRequest($request); if ($form->isValid()) { $this->service->add($form->getData()); return $this->redirect($this->generateUrl('app_admin_blogpost_complete')); } return $this->render('Admin/Blog/index.html.twig', ['form' => $form->createView()]); }
/** * @test */ public function addSuccess() { $blog_article = new BlogArticle(); $blog_article->setId(1); $blog_article->setTitle('test'); $blog_article->setContent('content'); $blog_article->setCategory($this->createCategory(1)); $this->repository->expects($this->once())->method('add'); $result = $this->blog_service->add($blog_article); $this->assertInstanceOf('AppBundle\\Entity\\BlogArticle', $result); $this->assertInstanceOf('AppBundle\\Entity\\Category', $result->getCategory()); }