Exemplo n.º 1
0
 public function testGetEntityDocumentWithoutDocument()
 {
     $mediawikiApiMock = $this->getMockBuilder('Mediawiki\\Api\\MediawikiApi')->disableOriginalConstructor()->getMock();
     $mediawikiApiMock->expects($this->once())->method('getRequest')->with($this->equalTo(new SimpleRequest('wbgetentities', ['ids' => 'Q42', 'languages' => 'en|fr'])))->will($this->returnValue(['entities' => []]));
     $serializationFactory = new EntitySerializationFactory();
     $lookup = new ApiEntityLookup($mediawikiApiMock, $serializationFactory->newEntityDeserializer(), new EntityStoreOptions([EntityStore::OPTION_LANGUAGES => ['en', 'fr'], EntityStore::OPTION_LANGUAGE_FALLBACK => false]));
     $this->assertNull($lookup->getEntityDocumentForId(new ItemId('Q42')));
 }
 public function testGetEntityDocumentWithException()
 {
     $mediawikiApiMock = $this->getMockBuilder('Mediawiki\\Api\\MediawikiApi')->disableOriginalConstructor()->getMock();
     $mediawikiApiMock->expects($this->once())->method('getRequest')->with($this->equalTo(new SimpleRequest('wbgetentities', array('ids' => 'Q42', 'languages' => 'en|fr'))))->will($this->returnValue(array('entities' => array())));
     $serializationFactory = new EntitySerializationFactory();
     $lookup = new ApiEntityLookup($mediawikiApiMock, $serializationFactory->newEntityDeserializer(), new EntityStoreOptions(array(EntityStore::OPTION_LANGUAGES => array('en', 'fr'), EntityStore::OPTION_LANGUAGE_FALLBACK => false)));
     $this->setExpectedException('Wikibase\\EntityStore\\EntityNotFoundException');
     $lookup->getEntityDocumentForId(new ItemId('Q42'));
 }
 private function newEntityLookup(MediawikiApi $api)
 {
     $serializationFactory = new EntitySerializationFactory();
     return new EntityLookup(new ApiEntityLookup($api, $serializationFactory->newEntityDeserializer(), $this->getOptions()));
 }
Exemplo n.º 4
0
 private function newDocumentBuilder()
 {
     $serialization = new EntitySerializationFactory();
     return new MongoDBDocumentBuilder($serialization->newEntitySerializer(), $serialization->newEntityDeserializer(), new BasicEntityIdParser(), $this->getOptions());
 }