Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: Rework getter into provider in ResultBuilderTest
......................................................................

Rework getter into provider in ResultBuilderTest

Warning, do not merge this before all other patches that touch the
same file are merged! I will rebase this later.

Change-Id: I20e8bdc758e881d7a4d978b3dd55f269472b5524
---
M repo/tests/phpunit/includes/api/ResultBuilderTest.php
1 file changed, 24 insertions(+), 13 deletions(-)


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

diff --git a/repo/tests/phpunit/includes/api/ResultBuilderTest.php 
b/repo/tests/phpunit/includes/api/ResultBuilderTest.php
index 4177018..6e4a7fd 100644
--- a/repo/tests/phpunit/includes/api/ResultBuilderTest.php
+++ b/repo/tests/phpunit/includes/api/ResultBuilderTest.php
@@ -594,17 +594,18 @@
                $this->assertEquals( $expected, $data );
        }
 
-       public function testAddClaims() {
+       /**
+        * @dataProvider statementSerializationProvider
+        */
+       public function testAddClaims( Statement $statement, 
$statementSerialization ) {
                $result = $this->getDefaultResult();
-               list( $statement, $expectedStatementSerialization ) = 
$this->getClaimAndExpectedSerialization();
-               $claims = array( $statement );
                $path = array( 'entities', 'Q1' );
                $expected = array(
                        'entities' => array(
                                'Q1' => array(
                                        'claims' => array(
                                                'P12' => array(
-                                                       
$expectedStatementSerialization
+                                                       $statementSerialization
                                                ),
                                        ),
                                ),
@@ -612,7 +613,7 @@
                );
 
                $resultBuilder = $this->getResultBuilder( $result );
-               $resultBuilder->addClaims( $claims, $path );
+               $resultBuilder->addClaims( array( $statement ), $path );
 
                $data = $result->getResultData( null, array(
                        'BC' => array(),
@@ -622,10 +623,12 @@
                $this->assertEquals( $expected, $data );
        }
 
-       public function testAddClaim() {
+       /**
+        * @dataProvider statementSerializationProvider
+        */
+       public function testAddClaim( Statement $statement, 
$statementSerialization ) {
                $result = $this->getDefaultResult();
-               list( $statement, $expectedStatementSerialization ) = 
$this->getClaimAndExpectedSerialization();
-               $expected = array( 'claim' => $expectedStatementSerialization );
+               $expected = array( 'claim' => $statementSerialization );
 
                $resultBuilder = $this->getResultBuilder( $result );
                $resultBuilder->addClaim( $statement );
@@ -638,13 +641,19 @@
                $this->assertEquals( $expected, $data );
        }
 
-       private function getClaimAndExpectedSerialization() {
+       public function statementSerializationProvider() {
                $statement = new Statement(
                        new PropertyValueSnak( new PropertyId( 'P12' ), new 
StringValue( 'stringVal' ) ),
-                       new SnakList( array( new PropertyValueSnak( new 
PropertyId( 'P12' ), new StringValue( 'qualiferVal' ) ) ) ),
-                       new Referencelist( array( new Reference( array( new 
PropertyValueSnak( new PropertyId( 'P12' ), new StringValue( 'refSnakVal' ) ) ) 
) ) )
+                       new SnakList( array(
+                               new PropertyValueSnak( new PropertyId( 'P12' ), 
new StringValue( 'qualiferVal' ) ),
+                       ) ),
+                       new Referencelist( array(
+                               new Reference( array(
+                                       new PropertyValueSnak( new PropertyId( 
'P12' ), new StringValue( 'refSnakVal' ) ),
+                               ) ),
+                       ) ),
+                       'fooguidbar'
                );
-               $statement->setGuid( 'fooguidbar' );
 
                $expectedSerialization = array(
                        'id' => 'fooguidbar',
@@ -695,7 +704,9 @@
                        ),
                );
 
-               return array( $statement, $expectedSerialization );
+               return array(
+                       array( $statement, $expectedSerialization ),
+               );
        }
 
        public function testAddReference() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I20e8bdc758e881d7a4d978b3dd55f269472b5524
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

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

Reply via email to