Addshore has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/227686

Change subject: WIP API BREAK
......................................................................

WIP API BREAK

Making raw/normal serialization the same

removing use of getRawMode!

Change-Id: I6b8a041917304bb9c78153da5bd71327b83699c6
---
M lib/includes/serialization/CallbackFactory.php
M repo/includes/LinkedData/EntityDataSerializationService.php
M repo/includes/api/ApiHelperFactory.php
M repo/includes/api/ResultBuilder.php
M repo/tests/phpunit/data/api/getentities.xml
M repo/tests/phpunit/data/api/setaliases.xml
M repo/tests/phpunit/includes/api/ResultBuilderTest.php
7 files changed, 119 insertions(+), 178 deletions(-)


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

diff --git a/lib/includes/serialization/CallbackFactory.php 
b/lib/includes/serialization/CallbackFactory.php
index 61e6b5d..8107570 100644
--- a/lib/includes/serialization/CallbackFactory.php
+++ b/lib/includes/serialization/CallbackFactory.php
@@ -29,20 +29,19 @@
        }
 
        /**
-        * Get callable to remove array keys and optionally set the key as an 
array value
+        * Get callable to set the keys in an array as values
         *
-        * @param string|null $addAsArrayElement
+        * @param string $elementKey
         *
         * @return callable
         */
-       public function getCallbackToRemoveKeys( $addAsArrayElement = null ) {
-               return function ( $array ) use ( $addAsArrayElement ) {
-                       if ( $addAsArrayElement !== null ) {
-                               foreach ( $array as $key => &$value ) {
-                                       $value[$addAsArrayElement] = $key;
+       public function getCallbackToAddKeysAsElement( $elementKey ) {
+               return function ( $array ) use ( $elementKey ) {
+                       foreach ( $array as $key => &$value ) {
+                               if ( is_array( $value ) ) {
+                                       $value[$elementKey] = $key;
                                }
                        }
-                       $array = array_values( $array );
                        return $array;
                };
        }
diff --git a/repo/includes/LinkedData/EntityDataSerializationService.php 
b/repo/includes/LinkedData/EntityDataSerializationService.php
index 7c53d98..ad41f3e 100644
--- a/repo/includes/LinkedData/EntityDataSerializationService.php
+++ b/repo/includes/LinkedData/EntityDataSerializationService.php
@@ -452,7 +452,7 @@
                        $this->serializerFactory,
                        $this->siteStore,
                        $this->propertyLookup,
-                       false // Never index tags for this service as we dont 
output XML
+                       false // Never add meta data for this service
                );
                $resultBuilder->addEntityRevision( null, $entityRevision );
 
diff --git a/repo/includes/api/ApiHelperFactory.php 
b/repo/includes/api/ApiHelperFactory.php
index 8eb8a01..019163a 100644
--- a/repo/includes/api/ApiHelperFactory.php
+++ b/repo/includes/api/ApiHelperFactory.php
@@ -99,7 +99,7 @@
                        $this->newSerializerFactory(),
                        $this->siteStore,
                        $this->dataTypeLookup,
-                       $api->getResult()->getIsRawMode()
+                       true // The mediawiki api should always be given 
metadata
                );
        }
 
diff --git a/repo/includes/api/ResultBuilder.php 
b/repo/includes/api/ResultBuilder.php
index 45202e7..a34968b 100644
--- a/repo/includes/api/ResultBuilder.php
+++ b/repo/includes/api/ResultBuilder.php
@@ -75,9 +75,9 @@
        private $callbackFactory;
 
        /**
-        * @var bool when special elements such as '_element' are needed by the 
formatter.
+        * @var bool when metadata elements should be added, see 
ApiResult::META_*
         */
-       private $isRawMode;
+       private $addMetaData;
 
        /**
         * @param ApiResult $result
@@ -85,7 +85,8 @@
         * @param SerializerFactory $serializerFactory
         * @param SiteStore $siteStore
         * @param PropertyDataTypeLookup $dataTypeLookup
-        * @param bool $isRawMode when special elements such as '_element' are 
needed by the formatter.
+        * @param bool $addMetaData when metadata elements should be added, see 
ApiResult::META_*
+        *     This is generally true for the api and false for everything else.
         */
        public function __construct(
                ApiResult $result,
@@ -93,13 +94,13 @@
                SerializerFactory $serializerFactory,
                SiteStore $siteStore,
                PropertyDataTypeLookup $dataTypeLookup,
-               $isRawMode
+               $addMetaData
        ) {
                $this->result = $result;
                $this->entityTitleLookup = $entityTitleLookup;
                $this->serializerFactory = $serializerFactory;
                $this->missingEntityCounter = -1;
-               $this->isRawMode = $isRawMode;
+               $this->addMetaData = $addMetaData;
                $this->siteStore = $siteStore;
                $this->dataTypeLookup = $dataTypeLookup;
                $this->modifier = new SerializationModifier();
@@ -146,7 +147,7 @@
                Assert::parameterType( 'string', $name, '$name' );
                Assert::parameterType( 'string', $tag, '$tag' );
 
-               if ( $this->isRawMode ) {
+               if ( $this->addMetaData ) {
                        // Unset first, so we don't make the tag name an actual 
value.
                        // We'll be setting this to $tag by calling 
setIndexedTagName().
                        unset( $values['_element'] );
@@ -197,7 +198,6 @@
         *
         * @param $path array|string|null
         * @param $key int|string|null the key to use when appending, or null 
for automatic.
-        * May be ignored even if given, based on $this->result->getIsRawMode().
         * @param $value mixed
         * @param string $tag tag name to use for $value in indexed mode
         */
@@ -206,10 +206,6 @@
                $this->checkKeyType( $key );
                Assert::parameterType( 'string', $tag, '$tag' );
                $this->checkValueIsNotList( $value );
-
-               if ( $this->isRawMode ) {
-                       $key = null;
-               }
 
                $this->result->addValue( $path, $key, $value );
                $this->result->addIndexedTagName( $path, $tag );
@@ -350,8 +346,10 @@
                        $filterLangCodes
                );
 
-               if ( $this->isRawMode ) {
-                       $serialization = $this->getRawModeEntitySerialization( 
$serialization );
+               $serialization = $this->addKeysAsElementsInEntityArray( 
$serialization );
+
+               if ( $this->addMetaData ) {
+                       $serialization = $this->addMetaDataToEntityArray( 
$serialization );
                }
 
                return $serialization;
@@ -503,51 +501,28 @@
                return $serialization;
        }
 
-       private function getRawModeEntitySerialization( $serialization ) {
-               // In raw mode aliases are not currently grouped by language
-               $serialization = $this->modifier->modifyUsingCallback(
-                       $serialization,
-                       'aliases',
-                       function( $array ) {
-                               $newArray = array();
-                               foreach ( $array as $aliasGroup ) {
-                                       foreach ( $aliasGroup as $alias ) {
-                                               $newArray[] = $alias;
-                                       }
-                               }
-                               return $newArray;
-                       }
-               );
-               // In the old Lib serializers
-               $serialization = $this->modifier->modifyUsingCallback(
-                       $serialization,
-                       'claims/*/*',
-                       function( $array ) {
-                               if ( !array_key_exists( 'qualifiers', $array ) 
) {
-                                       $array['qualifiers'] = array();
-                               }
-                               if ( !array_key_exists( 'qualifiers-order', 
$array ) ) {
-                                       $array['qualifiers-order'] = array();
-                               }
-                               return $array;
-                       }
-               );
-               $keysToValues = array(
-                       'aliases' => null,
-                       'descriptions' => null,
-                       'labels' => null,
+       private function addKeysAsElementsInEntityArray( $serialization ) {
+               $keysToElements = array(
+                       //TODO something needs to be done with these tags 
'aliases' => null,
+                       //TODO something needs to be done with these tags 
'descriptions' => null,
+                       //TODO something needs to be done with these tags 
'labels' => null,
                        'claims/*/*/references/*/snaks' => 'id',
                        'claims/*/*/qualifiers' => 'id',
                        'claims' => 'id',
-                       'sitelinks' => null,
+                       //TODO something needs to be done with these tags 
'sitelinks' => null,
                );
-               foreach ( $keysToValues as $path => $newKey ) {
+               foreach ( $keysToElements as $path => $newKey ) {
+                       //TODO we no longer remove these keys, but the formater 
should ignore them!! :(
                        $serialization = $this->modifier->modifyUsingCallback(
                                $serialization,
                                $path,
-                               
$this->callbackFactory->getCallbackToRemoveKeys( $newKey )
+                               
$this->callbackFactory->getCallbackToAddKeysAsElement( $newKey )
                        );
                }
+               return $serialization;
+       }
+
+       private function addMetaDataToEntityArray( $serialization ) {
                $tagsToAdd = array(
                        'labels' => 'label',
                        'descriptions' => 'description',
@@ -674,17 +649,12 @@
         * @param array|string $path where the data is located
         */
        public function addAliasGroupList( AliasGroupList $aliasGroupList, 
$path ) {
-               if ( $this->isRawMode ) {
-                       $serializer = 
$this->serializerFactory->newAliasGroupSerializer();
-                       $values = array();
-                       foreach ( $aliasGroupList->toArray() as $aliasGroup ) {
-                               $values = array_merge( $values, 
$serializer->serialize( $aliasGroup ) );
-                       }
-               } else {
-                       $serializer = 
$this->serializerFactory->newAliasGroupListSerializer();
-                       $values = $serializer->serialize( $aliasGroupList );
-               }
-               $this->setList( $path, 'aliases', $values, 'alias' );
+               $serializer = 
$this->serializerFactory->newAliasGroupListSerializer();
+               $values = $serializer->serialize( $aliasGroupList );
+
+               //TODO need to add metadata / index tags here
+
+               $this->setList( $path, 'aliases', $values, 'language' );
        }
 
        /**
@@ -710,8 +680,8 @@
                        $values = $this->getSiteLinkListArrayWithUrls( $values 
);
                }
 
-               if ( $this->isRawMode ) {
-                       $values = $this->getRawModeSiteLinkListArray( $values );
+               if ( $this->addMetaData ) {
+                       $values = $this->addMetaDataToSiteLinkListArray( 
$values );
                }
 
                $this->setList( $path, 'sitelinks', $values, 'sitelink' );
@@ -729,7 +699,7 @@
                return $this->modifier->modifyUsingCallback( $array, '*', 
$addUrlCallback );
        }
 
-       private function getRawModeSiteLinkListArray( array $array ) {
+       private function addMetaDataToSiteLinkListArray( array $array ) {
                $addIndexedBadgesCallback = function ( $array ) {
                        ApiResult::setIndexedTagName( $array, 'badge' );
                        return $array;
@@ -782,15 +752,16 @@
                        );
                }
 
-               if ( !$this->isRawMode ) {
-                       $values = $this->getArrayWithAlteredClaims( $values, 
false, '*/*/' );
+               if ( !$this->addMetaData ) {
+                       $values = $this->getArrayWithAlteredClaims( $values, 
'*/*/' );
                } else {
-                       $values = $this->getArrayWithAlteredClaims( $values, 
true, '*/*/' );
-                       $values = $this->getArrayWithRawModeClaims( $values, 
'*/*/' );
+                       $values = $this->getArrayWithAlteredClaims( $values, 
'*/*/' );
+                       $values = $this->addMetaDataToClaimsArray( $values, 
'*/*/' );
+                       //TODO we no longer remove these keys, but the formater 
should ignore them!! :(
                        $values = $this->modifier->modifyUsingCallback(
                                $values,
                                null,
-                               
$this->callbackFactory->getCallbackToRemoveKeys( 'id' )
+                               
$this->callbackFactory->getCallbackToAddKeysAsElement( 'id' )
                        );
                        $values = $this->modifier->modifyUsingCallback(
                                $values,
@@ -820,8 +791,8 @@
 
                $value = $this->getArrayWithAlteredClaims( $value );
 
-               if ( $this->isRawMode ) {
-                       $value = $this->getArrayWithRawModeClaims( $value );
+               if ( $this->addMetaData ) {
+                       $value = $this->addMetaDataToClaimsArray( $value );
                }
 
                $this->setValue( null, 'claim', $value );
@@ -829,39 +800,11 @@
 
        /**
         * @param array $array
-        * @param bool $allowEmptyQualifiers
         * @param string $claimPath to the claim array/arrays with trailing /
         *
         * @return array
         */
-       private function getArrayWithAlteredClaims(
-               array $array,
-               $allowEmptyQualifiers = true,
-               $claimPath = ''
-       ) {
-               if ( $allowEmptyQualifiers ) {
-                       /**
-                        * Below we force an empty qualifiers and 
qualifiers-order element in the output.
-                        * This is to make sure we dont break anything that 
assumes this is always here.
-                        * This hack was added when moving away from the Lib 
serializers
-                        * TODO: remove this hack when we make other 'breaking 
changes' to the api output
-                        */
-                       $array = $this->modifier->modifyUsingCallback(
-                               $array,
-                               trim( $claimPath, '/' ),
-                               function ( $array ) {
-                                       if ( !isset( $array['qualifiers'] ) ) {
-                                               $array['qualifiers'] = array();
-                                       }
-                                       if ( !isset( $array['qualifiers-order'] 
) ) {
-                                               $array['qualifiers-order'] = 
array();
-                                       }
-
-                                       return $array;
-                               }
-                       );
-               }
-
+       private function getArrayWithAlteredClaims( array $array, $claimPath = 
'' ) {
                $array = $this->getArrayWithDataTypesInGroupedSnakListAtPath(
                        $array,
                        $claimPath . 'references/*/snaks'
@@ -875,6 +818,20 @@
                        $claimPath . 'mainsnak',
                        $this->callbackFactory->getCallbackToAddDataTypeToSnak( 
$this->dataTypeLookup )
                );
+
+               //TODO we no longer remove these keys, but the formater should 
ignore them!! :(
+               $array = $this->modifier->modifyUsingCallback(
+                       $array,
+                       $claimPath . 'references/*/snaks',
+                       $this->callbackFactory->getCallbackToAddKeysAsElement( 
'id' )
+               );
+               //TODO we no longer remove these keys, but the formater should 
ignore them!! :(
+               $array = $this->modifier->modifyUsingCallback(
+                       $array,
+                       $claimPath . 'qualifiers',
+                       $this->callbackFactory->getCallbackToAddKeysAsElement( 
'id' )
+               );
+
                return $array;
        }
 
@@ -884,40 +841,19 @@
         *
         * @return array
         */
-       private function getArrayWithRawModeClaims( array $array, $claimPath = 
'' ) {
-               $rawModeModifications = array(
-                       'references/*/snaks/*' => array(
-                               $this->callbackFactory->getCallbackToIndexTags( 
'snak' ),
-                       ),
-                       'references/*/snaks' => array(
-                               
$this->callbackFactory->getCallbackToRemoveKeys( 'id' ),
-                               $this->callbackFactory->getCallbackToIndexTags( 
'property' ),
-                       ),
-                       'references/*/snaks-order' => array(
-                               $this->callbackFactory->getCallbackToIndexTags( 
'property' )
-                       ),
-                       'references' => array(
-                               $this->callbackFactory->getCallbackToIndexTags( 
'reference' ),
-                       ),
-                       'qualifiers/*' => array(
-                               $this->callbackFactory->getCallbackToIndexTags( 
'qualifiers' ),
-                       ),
-                       'qualifiers' => array(
-                               
$this->callbackFactory->getCallbackToRemoveKeys( 'id' ),
-                               $this->callbackFactory->getCallbackToIndexTags( 
'property' ),
-                       ),
-                       'qualifiers-order' => array(
-                               $this->callbackFactory->getCallbackToIndexTags( 
'property' )
-                       ),
-                       'mainsnak' => array(
-                               
$this->callbackFactory->getCallbackToAddDataTypeToSnak( $this->dataTypeLookup ),
-                       ),
+       private function addMetaDataToClaimsArray( array $array, $claimPath = 
'' ) {
+               $indexTagModifications = array(
+                       'references/*/snaks/*' => 
$this->callbackFactory->getCallbackToIndexTags( 'snak' ),
+                       'references/*/snaks' => 
$this->callbackFactory->getCallbackToIndexTags( 'property' ),
+                       'references/*/snaks-order' => 
$this->callbackFactory->getCallbackToIndexTags( 'property' ),
+                       'references' => 
$this->callbackFactory->getCallbackToIndexTags( 'reference' ),
+                       'qualifiers/*' => 
$this->callbackFactory->getCallbackToIndexTags( 'qualifiers' ),
+                       'qualifiers' => 
$this->callbackFactory->getCallbackToIndexTags( 'property' ),
+                       'qualifiers-order' => 
$this->callbackFactory->getCallbackToIndexTags( 'property' ),
                );
 
-               foreach ( $rawModeModifications as $path => $callbacks ) {
-                       foreach ( $callbacks as $callback ) {
-                               $array = $this->modifier->modifyUsingCallback( 
$array, $claimPath . $path, $callback );
-                       }
+               foreach ( $indexTagModifications as $path => $callback ) {
+                       $array = $this->modifier->modifyUsingCallback( $array, 
$claimPath . $path, $callback );
                }
 
                return $array;
@@ -941,8 +877,8 @@
 
                $value = $this->getArrayWithDataTypesInGroupedSnakListAtPath( 
$value, 'snaks' );
 
-               if ( $this->isRawMode ) {
-                       $value = $this->getRawModeReferenceArray( $value );
+               if ( $this->addMetaData ) {
+                       $value = $this->addMetaDataToReferenceArray( $value );
                }
 
                $this->setValue( null, 'reference', $value );
@@ -962,7 +898,7 @@
                );
        }
 
-       private function getRawModeReferenceArray( $array ) {
+       private function addMetaDataToReferenceArray( $array ) {
                $array = $this->modifier->modifyUsingCallback( $array, 
'snaks-order', function ( $array ) {
                        ApiResult::setIndexedTagName( $array, 'property' );
                        return $array;
diff --git a/repo/tests/phpunit/data/api/getentities.xml 
b/repo/tests/phpunit/data/api/getentities.xml
index 4ecdf20..86bca36 100644
--- a/repo/tests/phpunit/data/api/getentities.xml
+++ b/repo/tests/phpunit/data/api/getentities.xml
@@ -11,10 +11,14 @@
                                <description language="es" value="es-desc"/>
                        </descriptions>
                        <aliases>
-                               <alias language="pt" value="AA"/>
-                               <alias language="pt" value="BB"/>
-                               <alias language="en" value="AA-en"/>
-                               <alias language="en" value="BB-en"/>
+                               <language id="pt">
+                                       <alias language="pt" value="AA"/>
+                                       <alias language="pt" value="BB"/>
+                               </language>
+                               <language id="en">
+                                       <alias language="en" value="AA-en"/>
+                                       <alias language="en" value="BB-en"/>
+                               </language>
                        </aliases>
                        <claims>
                                <property id="$propertyIdUnderTest">
diff --git a/repo/tests/phpunit/data/api/setaliases.xml 
b/repo/tests/phpunit/data/api/setaliases.xml
index 301fe19..20e2c9f 100644
--- a/repo/tests/phpunit/data/api/setaliases.xml
+++ b/repo/tests/phpunit/data/api/setaliases.xml
@@ -2,9 +2,11 @@
 <api success="1">
        <entity id="$itemIdUnderTest" type="item">
                <aliases>
-                       <alias language="en-gb" value="AA"/>
-                       <alias language="en-gb" value="BB"/>
-                       <alias language="en-gb" value="CC"/>
+                       <language id="en-gb" >
+                               <alias language="en-gb" value="AA"/>
+                               <alias language="en-gb" value="BB"/>
+                               <alias language="en-gb" value="CC"/>
+                       </language>
                </aliases>
        </entity>
 </api>
\ No newline at end of file
diff --git a/repo/tests/phpunit/includes/api/ResultBuilderTest.php 
b/repo/tests/phpunit/includes/api/ResultBuilderTest.php
index 549fc83..67c6301 100644
--- a/repo/tests/phpunit/includes/api/ResultBuilderTest.php
+++ b/repo/tests/phpunit/includes/api/ResultBuilderTest.php
@@ -44,7 +44,7 @@
                return new ApiResult( false );
        }
 
-       protected function getResultBuilder( $result, $isRawMode = false ) {
+       protected function getResultBuilder( $result, $addMetaData = false ) {
                $mockTitle = $this->getMockBuilder( '\Title' )
                        ->disableOriginalConstructor()
                        ->getMock();
@@ -82,7 +82,7 @@
                        $serializerFactory,
                        new MockSiteStore(),
                        $mockPropertyDataTypeLookup,
-                       $isRawMode
+                       $addMetaData
                );
 
                return $builder;
@@ -261,7 +261,7 @@
                        ),
                );
 
-               $expectedRaw = array(
+               $expectedWithMetaData = array(
                        'entities' => array(
                                array(
                                        'pageid' => 123, //mocked
@@ -417,14 +417,14 @@
 
                return array(
                        array( false, $expected ),
-                       array( true, $expectedRaw ),
+                       array( true, $expectedWithMetaData ),
                );
        }
 
        /**
         * @dataProvider provideTestAddEntityRevision
         */
-       public function testAddEntityRevision( $isRawMode, $expected ) {
+       public function testAddEntityRevision( $addMetaData, $expected ) {
                $result = $this->getDefaultResult();
                $item = new Item( new ItemId( 'Q123098' ) );
 
@@ -455,7 +455,7 @@
 
                $entityRevision = new EntityRevision( $item, 33, 
'20131126202923' );
 
-               $resultBuilder = $this->getResultBuilder( $result, $isRawMode );
+               $resultBuilder = $this->getResultBuilder( $result, $addMetaData 
);
                $resultBuilder->addEntityRevision( 'Q1230000', $entityRevision 
);
 
                $data = $result->getResultData();
@@ -596,7 +596,7 @@
        /**
         * @dataProvider provideTestAddEntityRevisionFallback
         */
-       public function testAddEntityRevisionFallback( $indexedMode, $expected  
) {
+       public function testAddEntityRevisionFallback( $addMetaData, $expected  
) {
                $item = new Item( new ItemId( 'Q123101' ) );
                $item->getFingerprint()->setLabel( 'de', 'Oslo-de' );
                $item->getFingerprint()->setLabel( 'en', 'Oslo-en' );
@@ -618,7 +618,7 @@
                $filterLangCodes = array_keys( $fallbackChains );
 
                $result = $this->getDefaultResult();
-               $resultBuilder = $this->getResultBuilder( $result, $indexedMode 
);
+               $resultBuilder = $this->getResultBuilder( $result, $addMetaData 
);
                $resultBuilder->addEntityRevision(
                        null,
                        $entityRevision,
@@ -954,7 +954,7 @@
        /**
         * @dataProvider provideAddAliasGroupList
         */
-       public function testAddAliasGroupList( $rawMode, $expected ) {
+       public function testAddAliasGroupList( $addMetaData, $expected ) {
                $result = $this->getDefaultResult();
                $aliasGroupList = new AliasGroupList(
                        array(
@@ -964,7 +964,7 @@
                );
                $path = array( 'entities', 'Q1' );
 
-               $resultBuilder = $this->getResultBuilder( $result, $rawMode );
+               $resultBuilder = $this->getResultBuilder( $result, $addMetaData 
);
                $resultBuilder->addAliasGroupList( $aliasGroupList, $path );
 
                $data = $result->getResultData();
@@ -1023,7 +1023,7 @@
        /**
         * @dataProvider provideAddSiteLinkList
         */
-       public function testAddSiteLinkList( $isRawMode, $expected ) {
+       public function testAddSiteLinkList( $addMetaData, $expected ) {
                $result = $this->getDefaultResult();
                $siteLinkList = new SiteLinkList(
                        array(
@@ -1033,7 +1033,7 @@
                );
                $path = array( 'entities', 'Q1' );
 
-               $resultBuilder = $this->getResultBuilder( $result, $isRawMode );
+               $resultBuilder = $this->getResultBuilder( $result, $addMetaData 
);
                $resultBuilder->addSiteLinkList( $siteLinkList, $path );
 
                $data = $result->getResultData();
@@ -1136,11 +1136,11 @@
        /**
         * @dataProvider statementSerializationProvider
         */
-       public function testAddClaims( Statement $statement, $isRawMode, 
$statementSerialization ) {
+       public function testAddClaims( Statement $statement, $addMetaData, 
$statementSerialization ) {
                $result = $this->getDefaultResult();
                $path = array( 'entities', 'Q1' );
 
-               if ( $isRawMode ) {
+               if ( $addMetaData ) {
                        $expected = array(
                                'entities' => array(
                                        'Q1' => array(
@@ -1169,7 +1169,7 @@
                        );
                }
 
-               $resultBuilder = $this->getResultBuilder( $result, $isRawMode );
+               $resultBuilder = $this->getResultBuilder( $result, $addMetaData 
);
                $resultBuilder->addClaims( array( $statement ), $path );
 
                $data = $result->getResultData();
@@ -1226,11 +1226,11 @@
        /**
         * @dataProvider statementSerializationProvider
         */
-       public function testAddClaim( Statement $statement, $isRawMode, 
$statementSerialization ) {
+       public function testAddClaim( Statement $statement, $addMetaData, 
$statementSerialization ) {
                $result = $this->getDefaultResult();
                $expected = array( 'claim' => $statementSerialization );
 
-               $resultBuilder = $this->getResultBuilder( $result, $isRawMode );
+               $resultBuilder = $this->getResultBuilder( $result, $addMetaData 
);
                $resultBuilder->addClaim( $statement );
 
                $data = $result->getResultData();
@@ -1301,7 +1301,7 @@
                        ),
                );
 
-               $expectedRawModeSerialization = array(
+               $expectedSerializationWithMetaData = array(
                        'id' => 'fooguidbar',
                        'mainsnak' => array(
                                'snaktype' => 'value',
@@ -1365,7 +1365,7 @@
 
                return array(
                        array( $statement, false, $expectedSerialization ),
-                       array( $statement, true, $expectedRawModeSerialization 
),
+                       array( $statement, true, 
$expectedSerializationWithMetaData ),
                );
        }
 
@@ -1427,7 +1427,7 @@
        /**
         * @dataProvider provideAddReference
         */
-       public function testAddReference( $isRawMode, $expected ) {
+       public function testAddReference( $addMetaData, $expected ) {
                $result = $this->getDefaultResult();
                $reference = new Reference(
                        new SnakList( array(
@@ -1435,7 +1435,7 @@
                        ) )
                );
 
-               $resultBuilder = $this->getResultBuilder( $result, $isRawMode );
+               $resultBuilder = $this->getResultBuilder( $result, $addMetaData 
);
                $resultBuilder->addReference( $reference );
 
                $data = $result->getResultData();
@@ -1617,9 +1617,9 @@
        /**
         * @dataProvider provideSetList
         */
-       public function testSetList( $path, $name, array $values, $tag, 
$indexed, $expected ) {
+       public function testSetList( $path, $name, array $values, $tag, 
$addMetaData, $expected ) {
                $result = $this->getDefaultResult();
-               $builder = $this->getResultBuilder( $result, $indexed );
+               $builder = $this->getResultBuilder( $result, $addMetaData );
 
                $builder->setList( $path, $name, $values, $tag );
                $data = $result->getResultData();
@@ -1681,9 +1681,9 @@
        /**
         * @dataProvider provideSetValue
         */
-       public function testSetValue( $path, $name, $value, $indexed, $expected 
) {
+       public function testSetValue( $path, $name, $value, $addMetaData, 
$expected ) {
                $result = $this->getDefaultResult();
-               $builder = $this->getResultBuilder( $result, $indexed );
+               $builder = $this->getResultBuilder( $result, $addMetaData );
 
                $builder->setValue( $path, $name, $value );
                $data = $result->getResultData();
@@ -1764,9 +1764,9 @@
        /**
         * @dataProvider provideAppendValue
         */
-       public function testAppendValue( $path, $key, $value, $tag, $indexed, 
$expected ) {
+       public function testAppendValue( $path, $key, $value, $tag, 
$addMetaData, $expected ) {
                $result = $this->getDefaultResult();
-               $builder = $this->getResultBuilder( $result, $indexed );
+               $builder = $this->getResultBuilder( $result, $addMetaData );
 
                $builder->appendValue( $path, $key, $value, $tag );
                $data = $result->getResultData();

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

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

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

Reply via email to