private function newRequestHandler() { $mockRepository = EntityDataTestProvider::getMockRepository(); $titleLookup = $this->getMock('Wikibase\\Lib\\Store\\EntityTitleLookup'); $titleLookup->expects($this->any())->method('getTitleForId')->will($this->returnCallback(function (EntityId $id) { return Title::newFromText($id->getEntityType() . ':' . $id->getSerialization()); })); $dataTypeLookup = $this->getMock('Wikibase\\DataModel\\Services\\Lookup\\PropertyDataTypeLookup'); $dataTypeLookup->expects($this->any())->method('getDataTypeIdForProperty')->will($this->returnValue('string')); $entityDataFormatProvider = new EntityDataFormatProvider(); $serializerFactory = new SerializerFactory(new DataValueSerializer(), SerializerFactory::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH + SerializerFactory::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH); // Note: We are testing with the actual RDF bindings. These should not change for well // known data types. Mocking the bindings would be nice, but is complex and not needed. $rdfBuilder = WikibaseRepo::getDefaultInstance()->getValueSnakRdfBuilderFactory(); $serializationService = new EntityDataSerializationService(self::URI_BASE, self::URI_DATA, $mockRepository, $titleLookup, $dataTypeLookup, $rdfBuilder, new SiteList(), $entityDataFormatProvider, $serializerFactory, new HashSiteStore()); $formats = array('json', 'rdfxml', 'ntriples'); $entityDataFormatProvider->setFormatWhiteList($formats); $defaultFormat = 'rdf'; $supportedExtensions = array_combine($formats, $formats); $title = SpecialPage::getTitleFor('EntityData'); $uriManager = new EntityDataUriManager($title, $supportedExtensions, $titleLookup); $useSquid = false; $apiFrameOptions = 'DENY'; return new EntityDataRequestHandler($uriManager, $titleLookup, new BasicEntityIdParser(), $mockRepository, $mockRepository, $serializationService, $entityDataFormatProvider, $defaultFormat, 0, $useSquid, $apiFrameOptions); }
/** * @return EntityDataRequestHandler */ protected function newHandler() { $mockRepository = EntityDataTestProvider::getMockRepository(); $idParser = new BasicEntityIdParser(); // we only test for items and properties here. $dataTypeLookup = $this->getMock('Wikibase\\DataModel\\Services\\Lookup\\PropertyDataTypeLookup'); $dataTypeLookup->expects($this->any())->method('getDataTypeIdForProperty')->will($this->returnValue('string')); $titleLookup = $this->getMock('Wikibase\\Lib\\Store\\EntityTitleLookup'); $titleLookup->expects($this->any())->method('getTitleForId')->will($this->returnCallback(function (EntityId $id) { return Title::newFromText($id->getEntityType() . ':' . $id->getSerialization()); })); $propertyLookup = $this->getMock('Wikibase\\DataModel\\Services\\Lookup\\PropertyDataTypeLookup'); $entityDataFormatProvider = new EntityDataFormatProvider(); $serializerFactory = new SerializerFactory(new DataValueSerializer(), SerializerFactory::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH + SerializerFactory::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH); // Note: We are testing with the actual RDF bindings. These should not change for well // known data types. Mocking the bindings would be nice, but is complex and not needed. $rdfBuilder = WikibaseRepo::getDefaultInstance()->getValueSnakRdfBuilderFactory(); $service = new EntityDataSerializationService(EntityDataSerializationServiceTest::URI_BASE, EntityDataSerializationServiceTest::URI_DATA, $mockRepository, $titleLookup, $propertyLookup, $rdfBuilder, new SiteList(), $entityDataFormatProvider, $serializerFactory, new MockSiteStore()); $entityDataFormatProvider->setFormatWhiteList(array('json', 'php', 'rdfxml', 'n3', 'turtle', 'ntriples')); $extensions = array('json' => 'json', 'php' => 'php', 'rdfxml' => 'rdf', 'n3' => 'n3', 'turtle' => 'ttl', 'ntriples' => 'n3'); $uriManager = new EntityDataUriManager($this->interfaceTitle, $extensions, $titleLookup); $handler = new EntityDataRequestHandler($uriManager, $titleLookup, $idParser, $mockRepository, $mockRepository, $service, $entityDataFormatProvider, 'json', 1800, false, null); return $handler; }