jenkins-bot has submitted this change and it was merged. Change subject: Rework getter into provider in ResultBuilderTest ......................................................................
Rework getter into provider in ResultBuilderTest Change-Id: I20e8bdc758e881d7a4d978b3dd55f269472b5524 --- M repo/tests/phpunit/includes/api/ResultBuilderTest.php 1 file changed, 24 insertions(+), 13 deletions(-) Approvals: Addshore: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/tests/phpunit/includes/api/ResultBuilderTest.php b/repo/tests/phpunit/includes/api/ResultBuilderTest.php index b1af381..21d4f63 100644 --- a/repo/tests/phpunit/includes/api/ResultBuilderTest.php +++ b/repo/tests/phpunit/includes/api/ResultBuilderTest.php @@ -622,17 +622,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 ), ), ), @@ -640,17 +641,19 @@ ); $resultBuilder = $this->getResultBuilder( $result ); - $resultBuilder->addClaims( $claims, $path ); + $resultBuilder->addClaims( array( $statement ), $path ); $data = $result->getResultData(); $this->removeElementsWithKeysRecursively( $data, array( '_type' ) ); $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 ); @@ -660,13 +663,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', @@ -717,7 +726,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: merged Gerrit-Change-Id: I20e8bdc758e881d7a4d978b3dd55f269472b5524 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits