/**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->metadataFactory = $this->getMock('Revinate\\SearchBundle\\Lib\\Search\\Mapping\\ClassMetadataFactory');
     $this->searchClient = $this->getMockBuilder('Revinate\\SearchBundle\\Lib\\Search\\ElasticSearch\\Client')->disableOriginalConstructor()->getMock();
     $this->configuration = $this->getMock('Revinate\\SearchBundle\\Lib\\Search\\Configuration');
     $this->configuration->expects($this->once())->method('getClassMetadataFactory')->will($this->returnValue($this->metadataFactory));
     $this->configuration->expects($this->once())->method('getMetadataCacheImpl')->will($this->returnValue($this->getMock('Lib\\Common\\Cache\\ArrayCache')));
     $this->evm = new EventManager();
     $this->sm = new SearchManager($this->configuration, $this->searchClient, $this->evm);
 }
 /**
  * Get the fully qualified class-name from the namespace alias.
  *
  * @param string $namespaceAlias
  * @param string $simpleClassName
  *
  * @return string
  */
 protected function getFqcnFromAlias($namespaceAlias, $simpleClassName)
 {
     $fullClassName = '';
     $namespaces = $this->config->getEntityNamespaces();
     if (!empty($namespaces[$namespaceAlias])) {
         $fullClassName = $namespaces[$namespaceAlias] . '\\Entity\\' . $simpleClassName;
     }
     return $fullClassName;
 }
Esempio n. 3
0
 /**
  * Constructor
  *
  * @param Configuration $config
  * @param SearchClientInterface $client
  * @param EventManager $eventManager
  */
 public function __construct(Configuration $config, SearchClientInterface $client, EventManager $eventManager)
 {
     $this->configuration = $config;
     $this->client = $client;
     $this->eventManager = $eventManager;
     $this->metadataFactory = $this->configuration->getClassMetadataFactory();
     $this->metadataFactory->setSearchManager($this);
     $this->metadataFactory->setConfiguration($this->configuration);
     $this->metadataFactory->setCacheDriver($this->configuration->getMetadataCacheImpl());
     $this->serializer = $this->configuration->getEntitySerializer();
     $this->entityManager = $this->configuration->getEntityManager();
     $this->unitOfWork = new UnitOfWork($this);
 }
Esempio n. 4
0
 /**
  *
  * @param array $connection
  * @param array $paths Array of Paths where Search Entities are found
  * @param \AppKernel $kernel
  */
 public function __construct(array $connection, array $paths = array(), \AppKernel $kernel)
 {
     $cacheProvider = 'Doctrine\\Common\\Cache\\ArrayCache';
     //Annotation metadata driver
     $config = new Configuration();
     $md = $config->newDefaultAnnotationDriver($paths);
     $config->setMetadataDriverImpl($md);
     $config->setMetadataCacheImpl(new $cacheProvider());
     $config->setEntitySerializer(new CallbackSerializer('toESDocument', 'fromESDocument'));
     $bundles = $kernel->getBundles();
     $entityNamespaces = array();
     foreach ($bundles as $bundle) {
         $nameSpace = $bundle->getNamespace();
         $name = $bundle->getName();
         $entityNamespaces[$name] = $nameSpace;
     }
     $config->setEntityNamespaces($entityNamespaces);
     $client = new \Elastica\Client(array('connections' => array($connection)));
     $this->searchManager = new SearchManager($config, new \Revinate\SearchBundle\Lib\Search\ElasticSearch\Client($client), new EventManager());
     $this->mappingManager = new MappingManager($this->searchManager, $kernel->getEnvironment());
 }
 public function testGetClassMetadataFactoryName()
 {
     $this->configuration = new Configuration();
     $className = $this->configuration->getClassMetadataFactoryName();
     $this->assertEquals($className, 'Revinate\\SearchBundle\\Lib\\Search\\Mapping\\ClassMetadataFactory');
 }