Aude has uploaded a new change for review. https://gerrit.wikimedia.org/r/260726
Change subject: Shorten long lines of code in RunCrossCheckTest ...................................................................... Shorten long lines of code in RunCrossCheckTest with small amount of refactoring of guid generation in the tests, to help with the long lines and improve the code. Change-Id: Icdcd8ff94ab5d266a3ff597bc3ad69d16bc81178 --- M tests/phpunit/Api/RunCrossCheckTest.php 1 file changed, 23 insertions(+), 8 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikibaseQualityExternalValidation refs/changes/26/260726/1 diff --git a/tests/phpunit/Api/RunCrossCheckTest.php b/tests/phpunit/Api/RunCrossCheckTest.php index 3347625..e1f6e7b 100644 --- a/tests/phpunit/Api/RunCrossCheckTest.php +++ b/tests/phpunit/Api/RunCrossCheckTest.php @@ -91,29 +91,27 @@ $store->saveEntity( $itemQ1, 'TestEntityQ1', $GLOBALS['wgUser'], EDIT_NEW ); self::$idMap['Q1'] = $itemQ1->getId(); - $guidGenerator = new V4GuidGenerator(); - $dataValue = new EntityIdValue( new ItemId( IDENTIFIER_PROPERTY_QID ) ); $snak = new PropertyValueSnak( new PropertyId( INSTANCE_OF_PID ), $dataValue ); - $guid = self::$idMap['P3']->getSerialization() . StatementGuid::SEPARATOR . $guidGenerator->newGuid(); + $guid = $this->makeStatementGuid( self::$idMap['P3'] ); $propertyP3->getStatements()->addNewStatement( $snak, null, null, $guid ); $store->saveEntity( $propertyP3, 'TestEntityP3', $GLOBALS['wgUser'], EDIT_UPDATE ); $dataValue = new StringValue( 'foo' ); $snak = new PropertyValueSnak( self::$idMap['P1'], $dataValue ); - $guid = self::$idMap['Q1']->getSerialization() . StatementGuid::SEPARATOR . $guidGenerator->newGuid(); + $guid = $this->makeStatementGuid( self::$idMap['Q1'] ); self::$claimGuids['P1'] = $guid; $itemQ1->getStatements()->addNewStatement( $snak, null, null, $guid ); $dataValue = new StringValue( 'baz' ); $snak = new PropertyValueSnak( self::$idMap['P2'], $dataValue ); - $guid = self::$idMap['Q1']->getSerialization() . StatementGuid::SEPARATOR . $guidGenerator->newGuid(); + $guid = $this->makeStatementGuid( self::$idMap['Q1'] ); self::$claimGuids['P2'] = $guid; $itemQ1->getStatements()->addNewStatement( $snak, null, null, $guid ); $dataValue = new StringValue( '1234' ); $snak = new PropertyValueSnak( self::$idMap['P3'], $dataValue ); - $guid = self::$idMap['Q1']->getSerialization() . StatementGuid::SEPARATOR . $guidGenerator->newGuid(); + $guid = $this->makeStatementGuid( self::$idMap['Q1'] ); self::$claimGuids['P3'] = $guid; $itemQ1->getStatements()->addNewStatement( $snak, null, null, $guid ); @@ -175,13 +173,24 @@ ); } + private function makeStatementGuid( EntityId $id ) { + $guidGenerator = new V4GuidGenerator(); + + return $id->getSerialization() . StatementGuid::SEPARATOR . $guidGenerator->newGuid(); + } + public function testExecuteInvalidParams() { $params = array( 'action' => 'wbqevcrosscheck', 'entities' => 'Q1', 'claims' => 'randomClaimGuid' ); - $this->setExpectedException( 'UsageException', 'Either provide the ids of entities or ids of claims, that should be cross-checked.' ); + + $this->setExpectedException( + 'UsageException', + 'Either provide the ids of entities or ids of claims, that should be cross-checked.' + ); + $this->doApiRequest( $params ); } @@ -189,7 +198,13 @@ $params = array( 'action' => 'wbqevcrosscheck' ); - $this->setExpectedException( 'UsageException', 'A parameter that is required was missing (Either provide the ids of entities or ids of claims, that should be cross-checked.)' ); + + $this->setExpectedException( + 'UsageException', + 'A parameter that is required was missing (Either provide the ids of entities or ' + . 'ids of claims, that should be cross-checked.)' + ); + $this->doApiRequest( $params ); } -- To view, visit https://gerrit.wikimedia.org/r/260726 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icdcd8ff94ab5d266a3ff597bc3ad69d16bc81178 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikibaseQualityExternalValidation Gerrit-Branch: master Gerrit-Owner: Aude <aude.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits