コード例 #1
0
ファイル: CategoryServiceTest.php プロジェクト: ffff5912/Blog
 /**
  * @test
  */
 public function getAllSuccess()
 {
     $categories = new ArrayCollection();
     $categories->add($this->createCategory(1, 'test1'), $this->createCategory(2, 'test2'));
     $this->repository->expects($this->once())->method('findAll')->will($this->returnValue($categories));
     $result = $this->category_service->getAll();
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\ArrayCollection', $result);
     $this->assertInstanceOf('AppBundle\\Entity\\Category', $result->get(0));
     $this->assertTrue(1 === $result->get(0)->getId());
 }
コード例 #2
0
ファイル: CategoryController.php プロジェクト: ffff5912/Blog
 /**
  * @Route("/", name="admin_category")
  * @Method("get")
  */
 public function indexAction()
 {
     $categories = $this->service->getAll();
     return $this->render('Admin/Category/index.html.twig', ['categories' => $categories]);
 }