public function testGetRepositoryShouldResolveEntityShortName()
 {
     /** @var $finderMock \PHPUnit_Framework_MockObject_MockObject|\FOS\ElasticaBundle\Finder\TransformedFinder */
     $finderMock = $this->getMockBuilder('FOS\\ElasticaBundle\\Finder\\TransformedFinder')->disableOriginalConstructor()->getMock();
     /** @var $registryMock \PHPUnit_Framework_MockObject_MockObject|\Doctrine\Common\Persistence\ManagerRegistry */
     $registryMock = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock();
     $registryMock->method('getAliasNamespace')->with($this->equalTo('FOSElasticaBundle'))->willReturn('FOS\\ElasticaBundle\\Tests\\Manager');
     $mainManager = $this->getMockBuilder('FOS\\ElasticaBundle\\Manager\\RepositoryManagerInterface')->disableOriginalConstructor()->getMock();
     $mainManager->method('getRepository')->with($this->equalTo('index/type'))->willReturn(new Repository($finderMock));
     $entityName = 'FOS\\ElasticaBundle\\Tests\\Manager\\Entity';
     $manager = new RepositoryManager($registryMock, $mainManager);
     $manager->addEntity($entityName, 'index/type');
     $repository = $manager->getRepository('FOSElasticaBundle:Entity');
     $this->assertInstanceOf('FOS\\ElasticaBundle\\Repository', $repository);
 }
 public function testThatGetRepositoryWorksWithShortEntityName()
 {
     /** @var $finderMock \PHPUnit_Framework_MockObject_MockObject|\FOS\ElasticaBundle\Finder\TransformedFinder */
     $finderMock = $this->getMockBuilder('FOS\\ElasticaBundle\\Finder\\TransformedFinder')->disableOriginalConstructor()->getMock();
     /** @var $registryMock \PHPUnit_Framework_MockObject_MockObject|\Doctrine\Common\Persistence\ManagerRegistry */
     $registryMock = $this->getMockBuilder('Doctrine\\Common\\Persistence\\ManagerRegistry')->disableOriginalConstructor()->getMock();
     /** @var $readerMock \PHPUnit_Framework_MockObject_MockObject|\Doctrine\Common\Annotations\Reader */
     $readerMock = $this->getMockBuilder('Doctrine\\Common\\Annotations\\Reader')->disableOriginalConstructor()->getMock();
     $shortEntityName = 'TestBundle:Entity';
     $entityName = 'FOS\\ElasticaBundle\\Tests\\Manager\\Entity';
     $shortPath = 'TestBundle';
     $fullPath = 'FOS\\ElasticaBundle\\Tests\\Manager';
     $registryMock->expects($this->once())->method('getAliasNamespace')->with($this->equalTo($shortPath))->will($this->returnValue($fullPath));
     $manager = new RepositoryManager($registryMock, $readerMock);
     $manager->addEntity($entityName, $finderMock);
     $repository = $manager->getRepository($shortEntityName);
     $this->assertInstanceOf('FOS\\ElasticaBundle\\Repository', $repository);
 }
 /**
  * @param RepositoryManager $repositoryManager
  * @param string            $repositoryName
  * @param array             $searchFields
  */
 public function __construct(RepositoryManager $repositoryManager, $repositoryName, $searchFields)
 {
     $this->repositoryManager = $repositoryManager;
     $this->searchRepository = $repositoryManager->getRepository($repositoryName);
     $this->searchRepository->setSearchFields($searchFields);
 }