Пример #1
0
 function it_handles_a_find_query(Find $query, EntityRepository $repository, EntityManagerInterface $em)
 {
     $query->getEntityClass()->willReturn('Indigo\\Crud\\Stub\\Entity');
     $query->getId()->willReturn(1);
     $repository->find(1)->shouldBeCalled();
     $em->getRepository('Indigo\\Crud\\Stub\\Entity')->willReturn($repository);
     $this->handle($query);
 }
Пример #2
0
 /**
  * Returns an entity
  *
  * @param Find $query
  *
  * @return object|null
  */
 public function handle(Find $query)
 {
     $entityClass = $query->getEntityClass();
     $id = $query->getId();
     return $this->em->getRepository($entityClass)->find($id);
 }