Hoo man has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/346636 )

Change subject: dumpRdf: Allow creating truthy dumps
......................................................................

dumpRdf: Allow creating truthy dumps

This includes:
* RdfProducer::PRODUCE_TRUTHY_STATEMENTS
* RdfProducer::PRODUCE_PROPERTIES
* RdfProducer::PRODUCE_RESOLVED_ENTITIES
* RdfProducer::PRODUCE_NORMALIZED_VALUES

Bug: T155103
Change-Id: I8158770249d3d9e0418d082d8b68384bb4bf7751
---
M repo/includes/Dumpers/RdfDumpGenerator.php
M repo/includes/Rdf/RdfBuilder.php
M repo/maintenance/dumpRdf.php
R repo/tests/phpunit/data/rdf/RdfDumpGenerator/full-empty.nt
R repo/tests/phpunit/data/rdf/RdfDumpGenerator/full-entities.nt
R repo/tests/phpunit/data/rdf/RdfDumpGenerator/full-redirect.nt
C repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-empty.nt
A repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-entities.nt
A repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-redirect.nt
M repo/tests/phpunit/includes/Dumpers/RdfDumpGeneratorTest.php
10 files changed, 170 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/36/346636/1

diff --git a/repo/includes/Dumpers/RdfDumpGenerator.php 
b/repo/includes/Dumpers/RdfDumpGenerator.php
index 381a391..4a148f1 100644
--- a/repo/includes/Dumpers/RdfDumpGenerator.php
+++ b/repo/includes/Dumpers/RdfDumpGenerator.php
@@ -4,7 +4,6 @@
 
 use InvalidArgumentException;
 use MWContentSerializationException;
-use MWException;
 use PageProps;
 use SiteList;
 use Wikibase\DataModel\Entity\EntityId;
@@ -187,8 +186,41 @@
        }
 
        /**
+        * Get the producer setting for the given flavor.
+        *
+        * @param string|null $flavorName
+        *
+        * @return int
+        * @throws InvalidArgumentException
+        */
+       private static function getFlavor( $flavorName ) {
+               //Note: RdfProducer::PRODUCE_VERSION_INFO is not needed here as 
dumps
+               // include that per default.
+
+               switch ( $flavorName ) {
+                       case 'full':
+                               return RdfProducer::PRODUCE_ALL_STATEMENTS
+                                       | RdfProducer::PRODUCE_TRUTHY_STATEMENTS
+                                       | RdfProducer::PRODUCE_QUALIFIERS
+                                       | RdfProducer::PRODUCE_REFERENCES
+                                       | RdfProducer::PRODUCE_SITELINKS
+                                       | RdfProducer::PRODUCE_FULL_VALUES
+                                       | RdfProducer::PRODUCE_PAGE_PROPS
+                                       | 
RdfProducer::PRODUCE_NORMALIZED_VALUES;
+                       case 'truthy':
+                               return RdfProducer::PRODUCE_TRUTHY_STATEMENTS
+                                       | RdfProducer::PRODUCE_PROPERTIES
+                                       | RdfProducer::PRODUCE_NORMALIZED_VALUES
+                                       | 
RdfProducer::PRODUCE_RESOLVED_ENTITIES;
+               }
+
+               throw new InvalidArgumentException( "Unsupported flavor: 
$flavorName" );
+       }
+
+       /**
         * @param string                     $format
         * @param resource                   $output
+        * @param string                     $flavor Either "full" or "truthy"
         * @param SiteList                   $sites
         * @param EntityRevisionLookup       $entityRevisionLookup
         * @param PropertyDataTypeLookup     $propertyLookup
@@ -198,11 +230,12 @@
         * @param RdfVocabulary              $vocabulary
         * @param EntityTitleLookup          $titleLookup
         * @return static
-        * @throws MWException
+        * @throws InvalidArgumentException
         */
        public static function createDumpGenerator(
                $format,
                $output,
+               $flavor,
                SiteList $sites,
                EntityRevisionLookup $entityRevisionLookup,
                PropertyDataTypeLookup $propertyLookup,
@@ -214,14 +247,8 @@
        ) {
                $rdfWriter = self::getRdfWriter( $format );
                if ( !$rdfWriter ) {
-                       throw new MWException( "Unknown format: $format" );
+                       throw new InvalidArgumentException( "Unknown format: 
$format" );
                }
-
-               $flavor =
-                       RdfProducer::PRODUCE_ALL_STATEMENTS | 
RdfProducer::PRODUCE_TRUTHY_STATEMENTS |
-                       RdfProducer::PRODUCE_QUALIFIERS | 
RdfProducer::PRODUCE_REFERENCES |
-                       RdfProducer::PRODUCE_SITELINKS | 
RdfProducer::PRODUCE_FULL_VALUES |
-                       RdfProducer::PRODUCE_PAGE_PROPS | 
RdfProducer::PRODUCE_NORMALIZED_VALUES;
 
                $rdfBuilder = new RdfBuilder(
                        $sites,
@@ -229,7 +256,7 @@
                        $valueSnakRdfBuilderFactory,
                        $propertyLookup,
                        $entityRdfBuilderFactory,
-                       $flavor,
+                       self::getFlavor( $flavor ),
                        $rdfWriter,
                        new HashDedupeBag(),
                        $titleLookup
diff --git a/repo/includes/Rdf/RdfBuilder.php b/repo/includes/Rdf/RdfBuilder.php
index ee3ae48..3b33b9b 100644
--- a/repo/includes/Rdf/RdfBuilder.php
+++ b/repo/includes/Rdf/RdfBuilder.php
@@ -474,7 +474,7 @@
        }
 
        /**
-        * Create header structure for the dump
+        * Create header structure for the dump (includes 
RdfProducer::PRODUCE_VERSION_INFO)
         *
         * @param int $timestamp Timestamp (for testing)
         */
diff --git a/repo/maintenance/dumpRdf.php b/repo/maintenance/dumpRdf.php
index 5ee408c..a79b1d1 100644
--- a/repo/maintenance/dumpRdf.php
+++ b/repo/maintenance/dumpRdf.php
@@ -72,7 +72,8 @@
 
        public function __construct() {
                parent::__construct();
-               $this->addOption( 'format', "Set the dump format.", false, true 
);
+               $this->addOption( 'format', 'Set the dump format, such as "nt" 
or "ttl". Defaults to "ttl".', false, true );
+               $this->addOption( 'flavor', 'Set the flavor to produce. Can be 
either "full" or "truthy". Defaults to "full".', false, true );
        }
 
        /**
@@ -149,9 +150,12 @@
         * @return DumpGenerator
         */
        protected function createDumper( $output ) {
+               $flavor = $this->getOption( 'flavor', 'full' );
+
                return RdfDumpGenerator::createDumpGenerator(
                        $this->getOption( 'format', 'ttl' ),
                        $output,
+                       $flavor,
                        $this->siteLookup->getSites(),
                        $this->revisionLookup,
                        $this->propertyDatatypeLookup,
diff --git a/repo/tests/phpunit/data/rdf/RdfDumpGenerator/empty.nt 
b/repo/tests/phpunit/data/rdf/RdfDumpGenerator/full-empty.nt
similarity index 100%
rename from repo/tests/phpunit/data/rdf/RdfDumpGenerator/empty.nt
rename to repo/tests/phpunit/data/rdf/RdfDumpGenerator/full-empty.nt
diff --git a/repo/tests/phpunit/data/rdf/RdfDumpGenerator/entities.nt 
b/repo/tests/phpunit/data/rdf/RdfDumpGenerator/full-entities.nt
similarity index 100%
rename from repo/tests/phpunit/data/rdf/RdfDumpGenerator/entities.nt
rename to repo/tests/phpunit/data/rdf/RdfDumpGenerator/full-entities.nt
diff --git a/repo/tests/phpunit/data/rdf/RdfDumpGenerator/redirect.nt 
b/repo/tests/phpunit/data/rdf/RdfDumpGenerator/full-redirect.nt
similarity index 100%
rename from repo/tests/phpunit/data/rdf/RdfDumpGenerator/redirect.nt
rename to repo/tests/phpunit/data/rdf/RdfDumpGenerator/full-redirect.nt
diff --git a/repo/tests/phpunit/data/rdf/RdfDumpGenerator/empty.nt 
b/repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-empty.nt
similarity index 100%
copy from repo/tests/phpunit/data/rdf/RdfDumpGenerator/empty.nt
copy to repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-empty.nt
diff --git a/repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-entities.nt 
b/repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-entities.nt
new file mode 100644
index 0000000..1c76a57
--- /dev/null
+++ b/repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-entities.nt
@@ -0,0 +1,60 @@
+<http://wikiba.se/ontology-beta#Dump> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Dataset> .
+<http://wikiba.se/ontology-beta#Dump> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#Ontology> .
+<http://wikiba.se/ontology-beta#Dump> <http://creativecommons.org/ns#license> 
<http://creativecommons.org/publicdomain/zero/1.0/> .
+<http://wikiba.se/ontology-beta#Dump> <http://schema.org/softwareVersion> 
"0.0.5" .
+<http://wikiba.se/ontology-beta#Dump> <http://schema.org/dateModified> 
"1970-01-12T13:46:40Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://wikiba.se/ontology-beta#Dump> <http://www.w3.org/2002/07/owl#imports> 
<http://wikiba.se/ontology-1.0.owl> .
+<http://data.acme.test/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
+<http://data.acme.test/P10> <http://schema.org/about> <http://acme.test/P10> .
+<http://data.acme.test/P10> <http://schema.org/version> 
"12"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://data.acme.test/P10> <http://schema.org/dateModified> 
"1970-01-12T13:46:40Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://wikiba.se/ontology-beta#Property> .
+<http://acme.test/P10> <http://www.w3.org/2000/01/rdf-schema#label> 
"label:P10"@en .
+<http://acme.test/P10> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"label:P10"@en .
+<http://acme.test/P10> <http://schema.org/name> "label:P10"@en .
+<http://acme.test/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://wikiba.se/ontology-beta#Property> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#propertyType> 
<http://wikiba.se/ontology-beta#Wibblywobbly> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#directClaim> 
<http://acme.test/prop/direct/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#claim> 
<http://acme.test/prop/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#statementProperty> 
<http://acme.test/prop/statement/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#statementValue> 
<http://acme.test/prop/statement/value/P10> .
+<http://acme.test/P10> 
<http://wikiba.se/ontology-beta#statementValueNormalized> 
<http://acme.test/prop/statement/value-normalized/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#qualifier> 
<http://acme.test/prop/qualifier/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#qualifierValue> 
<http://acme.test/prop/qualifier/value/P10> .
+<http://acme.test/P10> 
<http://wikiba.se/ontology-beta#qualifierValueNormalized> 
<http://acme.test/prop/qualifier/value-normalized/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#reference> 
<http://acme.test/prop/reference/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#referenceValue> 
<http://acme.test/prop/reference/value/P10> .
+<http://acme.test/P10> 
<http://wikiba.se/ontology-beta#referenceValueNormalized> 
<http://acme.test/prop/reference/value-normalized/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#novalue> 
<http://acme.test/prop/novalue/P10> .
+<http://acme.test/prop/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/value/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/qualifier/value/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/value/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/value-normalized/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/qualifier/value-normalized/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/value-normalized/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/novalue/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#Class> .
+<http://acme.test/prop/novalue/P10> 
<http://www.w3.org/2002/07/owl#complementOf> _:genid1 .
+_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#Restriction> .
+_:genid1 <http://www.w3.org/2002/07/owl#onProperty> 
<http://acme.test/prop/direct/P10> .
+_:genid1 <http://www.w3.org/2002/07/owl#someValuesFrom> 
<http://www.w3.org/2002/07/owl#Thing> .
+<http://data.acme.test/Q30> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
+<http://data.acme.test/Q30> <http://schema.org/about> <http://acme.test/Q30> .
+<http://data.acme.test/Q30> <http://schema.org/version> 
"12"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://data.acme.test/Q30> <http://schema.org/dateModified> 
"1970-01-12T13:46:40Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q30> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://wikiba.se/ontology-beta#Item> .
+<http://acme.test/Q30> <http://www.w3.org/2000/01/rdf-schema#label> 
"label:Q30"@en .
+<http://acme.test/Q30> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"label:Q30"@en .
+<http://acme.test/Q30> <http://schema.org/name> "label:Q30"@en .
+<http://data.acme.test/Q40> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
+<http://data.acme.test/Q40> <http://schema.org/about> <http://acme.test/Q40> .
+<http://data.acme.test/Q40> <http://schema.org/version> 
"12"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://data.acme.test/Q40> <http://schema.org/dateModified> 
"1970-01-12T13:46:40Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/Q40> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://wikiba.se/ontology-beta#Item> .
+<http://acme.test/Q40> <http://www.w3.org/2000/01/rdf-schema#label> 
"label:Q40"@en .
+<http://acme.test/Q40> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"label:Q40"@en .
+<http://acme.test/Q40> <http://schema.org/name> "label:Q40"@en .
\ No newline at end of file
diff --git a/repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-redirect.nt 
b/repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-redirect.nt
new file mode 100644
index 0000000..ef817fd
--- /dev/null
+++ b/repo/tests/phpunit/data/rdf/RdfDumpGenerator/truthy-redirect.nt
@@ -0,0 +1,45 @@
+<http://wikiba.se/ontology-beta#Dump> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://schema.org/Dataset> .
+<http://wikiba.se/ontology-beta#Dump> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#Ontology> .
+<http://wikiba.se/ontology-beta#Dump> <http://creativecommons.org/ns#license> 
<http://creativecommons.org/publicdomain/zero/1.0/> .
+<http://wikiba.se/ontology-beta#Dump> <http://schema.org/softwareVersion> 
"0.0.5" .
+<http://wikiba.se/ontology-beta#Dump> <http://schema.org/dateModified> 
"1970-01-12T13:46:40Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://wikiba.se/ontology-beta#Dump> <http://www.w3.org/2002/07/owl#imports> 
<http://wikiba.se/ontology-1.0.owl> .
+<http://data.acme.test/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://schema.org/Dataset> .
+<http://data.acme.test/P10> <http://schema.org/about> <http://acme.test/P10> .
+<http://data.acme.test/P10> <http://schema.org/version> 
"12"^^<http://www.w3.org/2001/XMLSchema#integer> .
+<http://data.acme.test/P10> <http://schema.org/dateModified> 
"1970-01-12T13:46:40Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
+<http://acme.test/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://wikiba.se/ontology-beta#Property> .
+<http://acme.test/P10> <http://www.w3.org/2000/01/rdf-schema#label> 
"label:P10"@en .
+<http://acme.test/P10> <http://www.w3.org/2004/02/skos/core#prefLabel> 
"label:P10"@en .
+<http://acme.test/P10> <http://schema.org/name> "label:P10"@en .
+<http://acme.test/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://wikiba.se/ontology-beta#Property> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#propertyType> 
<http://wikiba.se/ontology-beta#Wibblywobbly> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#directClaim> 
<http://acme.test/prop/direct/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#claim> 
<http://acme.test/prop/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#statementProperty> 
<http://acme.test/prop/statement/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#statementValue> 
<http://acme.test/prop/statement/value/P10> .
+<http://acme.test/P10> 
<http://wikiba.se/ontology-beta#statementValueNormalized> 
<http://acme.test/prop/statement/value-normalized/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#qualifier> 
<http://acme.test/prop/qualifier/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#qualifierValue> 
<http://acme.test/prop/qualifier/value/P10> .
+<http://acme.test/P10> 
<http://wikiba.se/ontology-beta#qualifierValueNormalized> 
<http://acme.test/prop/qualifier/value-normalized/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#reference> 
<http://acme.test/prop/reference/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#referenceValue> 
<http://acme.test/prop/reference/value/P10> .
+<http://acme.test/P10> 
<http://wikiba.se/ontology-beta#referenceValueNormalized> 
<http://acme.test/prop/reference/value-normalized/P10> .
+<http://acme.test/P10> <http://wikiba.se/ontology-beta#novalue> 
<http://acme.test/prop/novalue/P10> .
+<http://acme.test/prop/P10> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/value/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/qualifier/value/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/value/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/statement/value-normalized/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/qualifier/value-normalized/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/reference/value-normalized/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#ObjectProperty> .
+<http://acme.test/prop/direct/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/statement/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/qualifier/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/reference/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#DatatypeProperty> .
+<http://acme.test/prop/novalue/P10> 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#Class> .
+<http://acme.test/prop/novalue/P10> 
<http://www.w3.org/2002/07/owl#complementOf> _:genid1 .
+_:genid1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> 
<http://www.w3.org/2002/07/owl#Restriction> .
+_:genid1 <http://www.w3.org/2002/07/owl#onProperty> 
<http://acme.test/prop/direct/P10> .
+_:genid1 <http://www.w3.org/2002/07/owl#someValuesFrom> 
<http://www.w3.org/2002/07/owl#Thing> .
+<http://acme.test/Q4242> <http://www.w3.org/2002/07/owl#sameAs> 
<http://acme.test/Q42> .
\ No newline at end of file
diff --git a/repo/tests/phpunit/includes/Dumpers/RdfDumpGeneratorTest.php 
b/repo/tests/phpunit/includes/Dumpers/RdfDumpGeneratorTest.php
index c6fcca3..8bcdf57 100644
--- a/repo/tests/phpunit/includes/Dumpers/RdfDumpGeneratorTest.php
+++ b/repo/tests/phpunit/includes/Dumpers/RdfDumpGeneratorTest.php
@@ -100,13 +100,14 @@
        }
 
        /**
+        * @param string $flavor
         * @param EntityDocument[] $entities
         * @param EntityId[] $redirects
         *
         * @return RdfDumpGenerator
         * @throws MWException
         */
-       protected function newDumpGenerator( array $entities = array(), array 
$redirects = array() ) {
+       protected function newDumpGenerator( $flavor, array $entities = [], 
array $redirects = [] ) {
                $out = fopen( 'php://output', 'w' );
 
                $entityLookup = $this->getMock( EntityLookup::class );
@@ -151,6 +152,7 @@
                return RdfDumpGenerator::createDumpGenerator(
                        'ntriples',
                        $out,
+                       $flavor,
                        $this->getSiteList(),
                        $entityRevisionLookup,
                        $dataTypeLookup,
@@ -160,7 +162,7 @@
                        new RdfVocabulary(
                                self::URI_BASE,
                                self::URI_DATA,
-                               array( 'test' => 'en-x-test' )
+                               [ 'test' => 'en-x-test' ]
                        ),
                        $this->getEntityTitleLookup()
                );
@@ -172,21 +174,24 @@
                $q40 = new ItemId( 'Q40' );
                $q4242 = new ItemId( 'Q4242' ); // hardcoded to be a redirect
 
-               return array(
-                       'empty' => array( array(), 'empty' ),
-                       'some entities' => array( array( $p10, $q30, $q40 ), 
'entities' ),
-                       'redirect' => array( array( $p10, $q4242 ), 'redirect' 
),
-               );
+               return [
+                       'full empty' => [ [], 'full', 'empty' ],
+                       'full some entities' => [ [ $p10, $q30, $q40 ], 'full', 
'entities' ],
+                       'full redirect' => [ [ $p10, $q4242 ], 'full', 
'redirect' ],
+                       'truthy empty' => [ [], 'truthy', 'empty' ],
+                       'truthy some entities' => [ [ $p10, $q30, $q40 ], 
'truthy', 'entities' ],
+                       'truthy redirect' => [ [ $p10, $q4242 ], 'truthy', 
'redirect' ],
+               ];
        }
 
        /**
         * @dataProvider idProvider
         */
-       public function testGenerateDump( array $ids, $dumpname ) {
+       public function testGenerateDump( array $ids, $flavor, $dumpname ) {
                $jsonTest = new JsonDumpGeneratorTest();
                $entities = $jsonTest->makeEntities( $ids );
-               $redirects = array( 'Q4242' => new ItemId( 'Q42' ) );
-               $dumper = $this->newDumpGenerator( $entities, $redirects );
+               $redirects = [ 'Q4242' => new ItemId( 'Q42' ) ];
+               $dumper = $this->newDumpGenerator( $flavor, $entities, 
$redirects );
                $dumper->setTimestamp( 1000000 );
                $jsonTest = new JsonDumpGeneratorTest();
                $pager = $jsonTest->makeIdPager( $ids );
@@ -194,14 +199,15 @@
                ob_start();
                $dumper->generateDump( $pager );
                $actual = ob_get_clean();
-               $expected = $this->getTestData()->getNTriples( $dumpname );
+               $expected = $this->getTestData()->getNTriples( $flavor . '-' . 
$dumpname );
+
                $this->helper->assertNTriplesEquals( $expected, $actual );
        }
 
        public function loadDataProvider() {
-               return array(
-                       'references' => array( array( new ItemId( 'Q7' ), new 
ItemId( 'Q9' ) ), 'refs' ),
-               );
+               return [
+                       'references' => [ [ new ItemId( 'Q7' ), new ItemId( 
'Q9' ) ], 'refs' ],
+               ];
        }
 
        /**
@@ -210,7 +216,7 @@
         * @param string $dumpname
         */
        public function testReferenceDedup( array $ids, $dumpname ) {
-               $entities = array();
+               $entities = [];
                $rdfTest = new RdfBuilderTest();
 
                foreach ( $ids as $id ) {
@@ -218,7 +224,7 @@
                        $entities[$id] = $rdfTest->getEntityData( $id );
                }
 
-               $dumper = $this->newDumpGenerator( $entities );
+               $dumper = $this->newDumpGenerator( 'full', $entities );
                $dumper->setTimestamp( 1000000 );
                $jsonTest = new JsonDumpGeneratorTest();
                $pager = $jsonTest->makeIdPager( $ids );

-- 
To view, visit https://gerrit.wikimedia.org/r/346636
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8158770249d3d9e0418d082d8b68384bb4bf7751
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Hoo man <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to