/**
  * @param int $flavor Bitmap for the output flavor, use RdfProducer::PRODUCE_XXX constants.
  * @param EntityId[] &$mentioned Receives any entity IDs being mentioned.
  * @param DedupeBag $dedupe A bag of reference hashes that should be considered "already seen".
  *
  * @return FullStatementRdfBuilder
  */
 private function newBuilder($flavor, array &$mentioned = array(), DedupeBag $dedupe = null)
 {
     $vocabulary = $this->getTestData()->getVocabulary();
     $writer = $this->getTestData()->getNTriplesWriter();
     $mentionTracker = $this->getMock('Wikibase\\Rdf\\EntityMentionListener');
     $mentionTracker->expects($this->any())->method('propertyMentioned')->will($this->returnCallback(function (EntityId $id) use(&$mentioned) {
         $key = $id->getSerialization();
         $mentioned[$key] = $id;
     }));
     // Note: using the actual factory here makes this an integration test!
     $valueBuilderFactory = WikibaseRepo::getDefaultInstance()->getValueSnakRdfBuilderFactory();
     if ($flavor & RdfProducer::PRODUCE_FULL_VALUES) {
         $valueWriter = $writer->sub();
         $statementValueBuilder = $valueBuilderFactory->getComplexValueSnakRdfBuilder($this->getTestData()->getVocabulary(), $valueWriter, $mentionTracker, new HashDedupeBag());
     } else {
         $statementValueBuilder = $valueBuilderFactory->getSimpleValueSnakRdfBuilder($this->getTestData()->getVocabulary(), $writer, $mentionTracker, new HashDedupeBag());
     }
     $snakRdfBuilder = new SnakRdfBuilder($vocabulary, $statementValueBuilder, $this->getTestData()->getMockRepository());
     $statementBuilder = new FullStatementRdfBuilder($vocabulary, $writer, $snakRdfBuilder);
     $statementBuilder->setDedupeBag($dedupe ?: new NullDedupeBag());
     if ($flavor & RdfProducer::PRODUCE_PROPERTIES) {
         $snakRdfBuilder->setEntityMentionListener($mentionTracker);
     }
     $statementBuilder->setProduceQualifiers($flavor & RdfProducer::PRODUCE_QUALIFIERS);
     $statementBuilder->setProduceReferences($flavor & RdfProducer::PRODUCE_REFERENCES);
     // HACK: stick the writer into a public field, for use by getDataFromBuilder()
     $statementBuilder->test_writer = $writer;
     return $statementBuilder;
 }
 /**
  * @return EntityRdfBuilder
  */
 private function newFullStatementRdfBuilder()
 {
     $snakBuilder = $this->newSnakBuilder($this->shouldProduce(RdfProducer::PRODUCE_FULL_VALUES) ? 'full' : 'simple');
     $builder = new FullStatementRdfBuilder($this->vocabulary, $this->writer, $snakBuilder);
     $builder->setDedupeBag($this->dedupBag);
     $builder->setProduceQualifiers($this->shouldProduce(RdfProducer::PRODUCE_QUALIFIERS));
     $builder->setProduceReferences($this->shouldProduce(RdfProducer::PRODUCE_REFERENCES));
     return $builder;
 }