/**
  * @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;
 }
 /**
  * @param string $propertyNamespace
  * @param string $propertyValueLName
  * @param string $dataType
  * @param Snak|null $snak
  * @param EntityId[] &$mentioned receives the IDs of any mentioned entities.
  *
  * @return SnakRdfBuilder
  */
 private function newBuilder($propertyNamespace, $propertyValueLName, $dataType, Snak $snak = null, array &$mentioned = array())
 {
     $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;
     }));
     $valueBuilder = $this->getMock('Wikibase\\Rdf\\ValueSnakRdfBuilder');
     if ($snak instanceof PropertyValueSnak) {
         $valueBuilder->expects($this->once())->method('addValue')->with($this->anything(), $propertyNamespace, $propertyValueLName, $dataType, $snak);
     } else {
         $valueBuilder->expects($this->never())->method('addValue');
     }
     $vocabulary = $this->getTestData()->getVocabulary();
     $builder = new SnakRdfBuilder($vocabulary, $valueBuilder, $this->getTestData()->getMockRepository());
     $builder->setEntityMentionListener($mentionTracker);
     return $builder;
 }
 /**
  * @param string $full
  *
  * @return SnakRdfBuilder
  */
 private function newSnakBuilder($full)
 {
     if ($full === 'full') {
         $statementValueBuilder = $this->valueSnakRdfBuilderFactory->getComplexValueSnakRdfBuilder($this->vocabulary, $this->writer, $this, $this->dedupBag);
     } else {
         $statementValueBuilder = $this->valueSnakRdfBuilderFactory->getSimpleValueSnakRdfBuilder($this->vocabulary, $this->writer, $this, $this->dedupBag);
     }
     $snakBuilder = new SnakRdfBuilder($this->vocabulary, $statementValueBuilder, $this->propertyLookup);
     $snakBuilder->setEntityMentionListener($this);
     return $snakBuilder;
 }