public function testGetQuery_DocumentnameMissing()
 {
     $document = new \SolrInputDocument();
     $query = new FindByDocumentNameQuery($document);
     try {
         $queryString = $query->getQueryString();
         $this->fail('an exception should be thrown');
     } catch (\RuntimeException $e) {
         $this->assertTrue(true);
     }
 }
Esempio n. 2
0
 public function findAll()
 {
     $mapper = $this->solr->getMapper();
     $mapper->setMappingCommand($this->solr->getCommandFactory()->get('all'));
     $metaInformation = $this->solr->getMetaFactory()->loadInformation($this->entity);
     $document = $mapper->toDocument($metaInformation);
     if (null === $document) {
         return null;
     }
     $document->deleteField('id');
     $query = new FindByDocumentNameQuery($document);
     $query->setEntity($this->entity);
     return $this->solr->query($query);
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function findAll()
 {
     $mapper = $this->solr->getMapper();
     $mapper->setMappingCommand($this->solr->getCommandFactory()->get('all'));
     $metaInformation = $this->solr->getMetaFactory()->loadInformation($this->entity);
     $document = $mapper->toDocument($metaInformation);
     if (null === $document) {
         return null;
     }
     $document->removeField('id');
     $query = new FindByDocumentNameQuery();
     $query->setRows(1000000);
     $query->setDocumentName($metaInformation->getDocumentName());
     $query->setIndex($metaInformation->getIndex());
     $query->setDocument($document);
     $query->setEntity($this->entity);
     $query->setSolr($this->solr);
     $query->setHydrationMode($this->hydrationMode);
     return $this->solr->query($query);
 }
Esempio n. 4
0
 public function testQuery_OneDocumentFound()
 {
     $arrayObj = new SolrDocumentStub(array('title_s' => 'title'));
     $responseArray['response']['docs'][] = $arrayObj;
     $this->solrClientFake->setResponse(new SolrResponseFake($responseArray));
     $solr = new SolrFacade($this->connectionFactory, $this->commandFactory, $this->eventManager, $this->metaFactory);
     $document = new \SolrInputDocument();
     $document->addField('document_name_s', 'name');
     $query = new FindByDocumentNameQuery($document);
     $query->setEntity(new ValidTestEntity());
     $entities = $solr->query($query);
     $this->assertEquals(1, count($entities));
 }
 /**
  * @expectedException \RuntimeException
  */
 public function testGetQuery_DocumentnameMissing()
 {
     $query = new FindByDocumentNameQuery();
     $query->setDocument(new Document());
     $query->getQuery();
 }
Esempio n. 6
0
 public function testQuery_OneDocumentFound()
 {
     $arrayObj = new SolrDocumentStub(array('title_s' => 'title'));
     $document = new Document();
     $document->addField('document_name_s', 'name');
     $query = new FindByDocumentNameQuery();
     $query->setDocumentName('name');
     $query->setDocument($document);
     $query->setEntity(new ValidTestEntity());
     $query->setIndex('index0');
     $this->assertQueryWasExecuted(array($arrayObj), 'index0');
     $solr = new Solr($this->solrClientFake, $this->commandFactory, $this->eventDispatcher, $this->metaFactory, $this->mapper);
     $entities = $solr->query($query);
     $this->assertEquals(1, count($entities));
 }