示例#1
0
 /**
  * @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()]);
 }
示例#2
0
 /**
  * @test
  */
 public function getAllPostsSuccess()
 {
     $blogs = new ArrayCollection();
     $blog_article = new BlogArticle();
     $blog_article->setId(1);
     $blog_article->setTitle('test');
     $blog_article->setContent('content');
     $blog_article->setCategory($this->createCategory(1));
     $blogs->add($blog_article);
     $blog_article = new BlogArticle();
     $blog_article->setId(2);
     $blog_article->setTitle('test_2');
     $blog_article->setContent('content_2');
     $blog_article->setCategory($this->createCategory(1));
     $blogs->add($blog_article);
     $this->repository->expects($this->once())->method('findAll')->will($this->returnValue($blogs));
     $posts = $this->blog_service->getAllPosts();
     $post = $posts->first();
     $this->assertCount(2, $posts->toArray());
     $this->assertInstanceOf('AppBundle\\Entity\\BlogArticle', $post);
     $this->assertEquals(1, $post->getId());
 }
示例#3
0
 /**
  * @Route("/", name="admin_blog_list")
  * @Method("get")
  */
 public function indexAction()
 {
     $blogs = $this->service->getAllPosts();
     return $this->render('Admin/index.html.twig', ['blogs' => $blogs]);
 }