/** * @see EntityDocumentLookup::getEntityDocumentsForTerm */ public function getEntityIdsForTerm(Term $term, $entityType) { $documents = $this->database->selectCollection($entityType)->find($this->buildGetEntityIdForTermQuery($term), array('_id' => 1)); $entities = array(); foreach ($documents as $document) { $entities[] = $this->documentBuilder->buildEntityIdForDocument($document); } return $entities; }
private function formatResults(Iterator $cursor) { $entityIds = array(); foreach ($cursor as $document) { $entityIds[] = $this->documentBuilder->buildEntityIdForDocument($document); } return $entityIds; }
public function testBuildEntityIdForDocumentWithException() { $entitySerializerMock = $this->getMock('Serializers\\Serializer'); $entityDeserializerMock = $this->getMock('Deserializers\\Deserializer'); $documentBuilder = new MongoDBDocumentBuilder($entitySerializerMock, $entityDeserializerMock, new BasicEntityIdParser(), new EntityStoreOptions(array(EntityStore::OPTION_LANGUAGES => null))); $this->setExpectedException('Wikibase\\DataModel\\Entity\\EntityIdParsingException'); $documentBuilder->buildEntityIdForDocument(array()); }