public function testGetQuery_IdMissing() { $document = new \SolrInputDocument(); $query = new FindByIdentifierQuery($document); try { $queryString = $query->getQueryString(); $this->fail('an exception should be thrown'); } catch (\RuntimeException $e) { $this->assertEquals('id should not be null', $e->getMessage()); } }
/** * @param object $entity */ public function removeDocument($entity) { $command = $this->commandFactory->get('identifier'); $this->entityMapper->setMappingCommand($command); $metaInformations = $this->metaInformationFactory->loadInformation($entity); if ($document = $this->entityMapper->toDocument($metaInformations)) { $deleteQuery = new FindByIdentifierQuery($document); $queryString = $deleteQuery->getQueryString(); try { $response = $this->solrClient->deleteByQuery($queryString); $this->solrClient->commit(); } catch (\Exception $e) { $errorEvent = new ErrorEvent(null, null, 'delete-document'); $errorEvent->setException($e); $this->eventManager->handle(EventManager::ERROR, $errorEvent); } $this->eventManager->handle(EventManager::DELETE, new Event($this->solrClient, $metaInformations)); } }