/** * @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()); }
/** * @Route("/", name="admin_category") * @Method("get") */ public function indexAction() { $categories = $this->service->getAll(); return $this->render('Admin/Category/index.html.twig', ['categories' => $categories]); }