public function testGetQuery_DocumentnameMissing()
 {
     $query = new FindByDocumentNameQuery();
     $query->setDocument(new Document());
     try {
         $query->getQuery();
         $this->fail('an exception should be thrown');
     } catch (\RuntimeException $e) {
         $this->assertTrue(true);
     }
 }
Esempio n. 2
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->setDocument($document);
     $query->setEntity($this->entity);
     $query->setSolr($this->solr);
     $query->setHydrationMode($this->hydrationMode);
     return $this->solr->query($query);
 }
 /**
  * @expectedException \RuntimeException
  */
 public function testGetQuery_DocumentnameMissing()
 {
     $query = new FindByDocumentNameQuery();
     $query->setDocument(new Document());
     $query->getQuery();
 }
Esempio n. 4
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));
 }