Exemple #1
0
 /**
  * Create concrete dumper instance
  * @param resource $output
  * @return DumpGenerator
  */
 protected function createDumper($output)
 {
     $serializerOptions = SerializerFactory::OPTION_SERIALIZE_MAIN_SNAKS_WITHOUT_HASH + SerializerFactory::OPTION_SERIALIZE_REFERENCE_SNAKS_WITHOUT_HASH;
     $serializerFactory = new SerializerFactory(new DataValueSerializer(), $serializerOptions);
     $entitySerializer = $serializerFactory->newEntitySerializer();
     $dataTypeLookup = $this->propertyDatatypeLookup;
     $dumper = new JsonDumpGenerator($output, $this->entityLookup, $entitySerializer, $this->entityPrefetcher, $dataTypeLookup);
     $dumper->setUseSnippets((bool) $this->getOption('snippet', false));
     return $dumper;
 }
 private function getJsonDumperWithExceptionHandler(array $ids, Exception $ex)
 {
     $entityLookup = $this->getEntityLookupThrows($ex);
     $out = fopen('php://output', 'w');
     $serializer = $this->serializerFactory->newEntitySerializer();
     $jsonDumper = new JsonDumpGenerator($out, $entityLookup, $serializer, new NullEntityPrefetcher(), $this->getMockPropertyDataTypeLookup());
     $exceptionHandler = $this->getMock('Wikibase\\Lib\\Reporting\\ExceptionHandler');
     $exceptionHandler->expects($this->exactly(count($ids)))->method('handleException');
     $jsonDumper->setExceptionHandler($exceptionHandler);
     return $jsonDumper;
 }