/** * @expectedException \RuntimeException */ public function testThatGetRepositoryThrowsExceptionIfCustomRepositoryNotFound() { /** @var $finderMock \PHPUnit_Framework_MockObject_MockObject|\FOS\ElasticaBundle\Finder\TransformedFinder */ $finderMock = $this->getMockBuilder('FOS\\ElasticaBundle\\Finder\\TransformedFinder')->disableOriginalConstructor()->getMock(); /** @var $readerMock \PHPUnit_Framework_MockObject_MockObject|\Doctrine\Common\Annotations\Reader */ $readerMock = $this->getMockBuilder('Doctrine\\Common\\Annotations\\Reader')->disableOriginalConstructor()->getMock(); $entityName = 'FOS\\ElasticaBundle\\Tests\\Manager\\Entity'; $manager = new RepositoryManager($readerMock); $manager->addEntity($entityName, $finderMock, 'FOS\\ElasticaBundle\\Tests\\MissingRepository'); $manager->getRepository('Missing Entity'); }
/** * Return repository for entity * * Returns custom repository if one specified otherwise * returns a basic repository. */ public function getRepository($entityName) { $realEntityName = $entityName; if (strpos($entityName, ':') !== false) { list($namespaceAlias, $simpleClassName) = explode(':', $entityName); $realEntityName = $this->managerRegistry->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName; } return parent::getRepository($realEntityName); }