/**
  * @param Entity[] $entities
  * @param EntityId[] $redirects
  *
  * @return RdfDumpGenerator
  * @throws MWException
  */
 protected function newDumpGenerator(array $entities = array(), array $redirects = array())
 {
     $out = fopen('php://output', 'w');
     $entityLookup = $this->getMock('Wikibase\\DataModel\\Services\\Lookup\\EntityLookup');
     $entityRevisionLookup = $this->getMock('Wikibase\\Lib\\Store\\EntityRevisionLookup');
     $dataTypeLookup = $this->getTestData()->getMockRepository();
     $entityLookup->expects($this->any())->method('getEntity')->will($this->returnCallback(function (EntityId $id) use($entities, $redirects) {
         $key = $id->getSerialization();
         if (isset($redirects[$key])) {
             throw new RevisionedUnresolvedRedirectException($id, $redirects[$key]);
         }
         if (isset($entities[$key])) {
             return $entities[$key];
         }
         return null;
     }));
     $entityRevisionLookup->expects($this->any())->method('getEntityRevision')->will($this->returnCallback(function (EntityId $id) use($entityLookup) {
         /** @var EntityLookup $entityLookup */
         $entity = $entityLookup->getEntity($id);
         if (!$entity) {
             return null;
         }
         return new EntityRevision($entity, 12, wfTimestamp(TS_MW, 1000000));
     }));
     // Note: we test against the actual RDF bindings here, so we get actual RDF.
     $rdfBuilderFactory = WikibaseRepo::getDefaultInstance()->getValueSnakRdfBuilderFactory();
     return RdfDumpGenerator::createDumpGenerator('ntriples', $out, self::URI_BASE, self::URI_DATA, $this->getSiteList(), $entityRevisionLookup, $dataTypeLookup, $rdfBuilderFactory, new NullEntityPrefetcher(), array('test' => 'en-x-test'));
 }
 /**
  * Create concrete dumper instance
  *
  * @param resource $output
  *
  * @return DumpGenerator
  */
 protected function createDumper($output)
 {
     $entityDataTitle = Title::makeTitle(NS_SPECIAL, 'EntityData');
     $languageCodes = array_merge($GLOBALS['wgDummyLanguageCodes'], WikibaseRepo::getDefaultInstance()->getSettings()->getSetting('canonicalLanguageCodes'));
     return RdfDumpGenerator::createDumpGenerator($this->getOption('format', 'ttl'), $output, $this->conceptBaseUri, $entityDataTitle->getCanonicalURL() . '/', $this->siteStore->getSites(), $this->revisionLookup, $this->propertyDatatypeLookup, $this->valueSnakRdfBuilderFactory, $this->entityPrefetcher, $languageCodes);
 }