Ejemplo n.º 1
0
 public function testResourceRepository()
 {
     $entityManager = $this->createEntityManagerMock();
     $entityManager->expects($this->exactly(3))->method('getClassMetadata')->with($this->identicalTo($entityName = 'entity'))->will($this->returnValue($classMetadata = $this->createClassMetadataMock()));
     $classMetadata->expects($this->exactly(3))->method('getName')->will($this->returnValue($entityName));
     $this->resourceRegistry->expects($this->once())->method('getIterator')->will($this->returnValue(new \ArrayIterator([$resource = $this->createResourceMock()])));
     $resource->expects($this->once())->method('getModel')->will($this->returnValue($entityName));
     $classMetadata->customRepositoryClassName = $repositoryClass = Repository::class;
     $this->assertInstanceOf($repositoryClass, $repository = $this->repositoryFactory->getRepository($entityManager, $entityName));
     $this->assertSame($repository, $this->repositoryFactory->getRepository($entityManager, $entityName));
 }
 /**
  * {@inheritdoc}
  */
 protected function createResourceRepository($class, EntityManagerInterface $entityManager, ClassMetadata $metadata, ResourceInterface $resource = null)
 {
     if ($resource !== null && is_a($class, TranslatableRepository::class, true)) {
         return new $class($entityManager, $metadata, $resource, $this->getLocaleContext());
     }
     return parent::createResourceRepository($class, $entityManager, $metadata, $resource);
 }