Daniel Kinzler has uploaded a new change for review.
https://gerrit.wikimedia.org/r/84975
Change subject: Remove formatting logic from ChangeOps
......................................................................
Remove formatting logic from ChangeOps
Instead of formatting summary args beforehand, pass
the objects as is, and leave it to the SummaryFormatter
to do the formatting.
Change-Id: I3cd556c871a0f641bbf0a010118566bedd7da998
---
M lib/includes/formatters/PropertyValueSnakFormatter.php
M repo/includes/api/CreateClaim.php
M repo/includes/api/RemoveClaims.php
M repo/includes/api/RemoveQualifiers.php
M repo/includes/api/RemoveReferences.php
M repo/includes/api/SetClaimValue.php
M repo/includes/api/SetQualifier.php
M repo/includes/api/SetStatementRank.php
M repo/includes/changeop/ChangeOpMainSnak.php
M repo/includes/changeop/ChangeOpQualifier.php
M repo/includes/changeop/ChangeOpReference.php
M repo/includes/changeop/ChangeOpStatementRank.php
M repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
M repo/tests/phpunit/includes/changeop/ChangeOpQualifierTest.php
M repo/tests/phpunit/includes/changeop/ChangeOpReferenceTest.php
M repo/tests/phpunit/includes/changeop/ChangeOpStatementRankTest.php
16 files changed, 68 insertions(+), 207 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/75/84975/1
diff --git a/lib/includes/formatters/PropertyValueSnakFormatter.php
b/lib/includes/formatters/PropertyValueSnakFormatter.php
index 24aa152..44eaa93 100644
--- a/lib/includes/formatters/PropertyValueSnakFormatter.php
+++ b/lib/includes/formatters/PropertyValueSnakFormatter.php
@@ -62,8 +62,14 @@
throw new InvalidArgumentException( "Not a
PropertyValueSnak: " . get_class( $snak ) );
}
- /* @var PropertyValueSnak $snak */
- $propertyType = $this->typeLookup->getDataTypeIdForProperty(
$snak->getPropertyId() );
+ try {
+ /* @var PropertyValueSnak $snak */
+ $propertyType =
$this->typeLookup->getDataTypeIdForProperty( $snak->getPropertyId() );
+ } catch ( PropertyNotFoundException $ex ) {
+ // If the property has been removed, we should still be
able to render the snak value, so don't fail here.
+ wfDebugLog( __CLASS__, __FUNCTION__ . ': Can\'t look up
data type for property ' . $snak->getPropertyId()->getPrefixedId() );
+ $propertyType = null;
+ }
$text = $this->formatValue( $snak->getDataValue(),
$propertyType );
return $text;
diff --git a/repo/includes/api/CreateClaim.php
b/repo/includes/api/CreateClaim.php
index 482bfcf..b660ca5 100644
--- a/repo/includes/api/CreateClaim.php
+++ b/repo/includes/api/CreateClaim.php
@@ -45,7 +45,7 @@
$snak = $this->claimModificationHelper->getSnakInstance(
$params, $propertyId );
$summary = $this->claimModificationHelper->createSummary(
$params, $this );
- $changeOp = new ChangeOpMainSnak( '', $snak,
WikibaseRepo::getDefaultInstance()->getIdFormatter(), new ClaimGuidGenerator(
$entity->getId() ) );
+ $changeOp = new ChangeOpMainSnak( '', $snak, new
ClaimGuidGenerator( $entity->getId() ) );
try {
$changeOp->apply( $entity, $summary );
diff --git a/repo/includes/api/RemoveClaims.php
b/repo/includes/api/RemoveClaims.php
index c34acc3..49e6b52 100644
--- a/repo/includes/api/RemoveClaims.php
+++ b/repo/includes/api/RemoveClaims.php
@@ -137,7 +137,7 @@
$guidGenerator = new ClaimGuidGenerator( $this->getEntityId(
$params ) );
foreach ( $params['claim'] as $guid ) {
- $changeOps[] = new ChangeOpMainSnak( $guid, null,
WikibaseRepo::getDefaultInstance()->getIdFormatter(), $guidGenerator );
+ $changeOps[] = new ChangeOpMainSnak( $guid, null,
$guidGenerator );
}
return $changeOps;
diff --git a/repo/includes/api/RemoveQualifiers.php
b/repo/includes/api/RemoveQualifiers.php
index 758a532..4d91edf 100644
--- a/repo/includes/api/RemoveQualifiers.php
+++ b/repo/includes/api/RemoveQualifiers.php
@@ -96,10 +96,9 @@
*/
protected function getChangeOps( $claimGuid, array $qualifierHashes ) {
$changeOps = array();
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
foreach ( $qualifierHashes as $qualifierHash ) {
- $changeOps[] = new ChangeOpQualifier( $claimGuid, null,
$qualifierHash, $idFormatter );
+ $changeOps[] = new ChangeOpQualifier( $claimGuid, null,
$qualifierHash );
}
return $changeOps;
diff --git a/repo/includes/api/RemoveReferences.php
b/repo/includes/api/RemoveReferences.php
index 24daf2a..b33f136 100644
--- a/repo/includes/api/RemoveReferences.php
+++ b/repo/includes/api/RemoveReferences.php
@@ -100,10 +100,9 @@
*/
protected function getChangeOps( $claimGuid, array $referenceHashes ) {
$changeOps = array();
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
foreach ( $referenceHashes as $referenceHash ) {
- $changeOps[] = new ChangeOpReference( $claimGuid, null,
$referenceHash, $idFormatter );
+ $changeOps[] = new ChangeOpReference( $claimGuid, null,
$referenceHash );
}
return $changeOps;
diff --git a/repo/includes/api/SetClaimValue.php
b/repo/includes/api/SetClaimValue.php
index 748a9a6..d45b06e 100644
--- a/repo/includes/api/SetClaimValue.php
+++ b/repo/includes/api/SetClaimValue.php
@@ -48,7 +48,6 @@
$changeOp = new ChangeOpMainSnak(
$claimGuid,
$snak,
- WikibaseRepo::getDefaultInstance()->getIdFormatter(),
$guidGenerator
);
diff --git a/repo/includes/api/SetQualifier.php
b/repo/includes/api/SetQualifier.php
index bc0bbe1..39b7e16 100644
--- a/repo/includes/api/SetQualifier.php
+++ b/repo/includes/api/SetQualifier.php
@@ -109,16 +109,15 @@
$params = $this->extractRequestParams();
$claimGuid = $params['claim'];
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
if ( isset( $params['snakhash'] ) ) {
$propertyId =
$this->claimModificationHelper->getEntityIdFromString( $params['property'] );
$newQualifier =
$this->claimModificationHelper->getSnakInstance( $params, $propertyId );
- $changeOp = new ChangeOpQualifier( $claimGuid,
$newQualifier, $params['snakhash'], $idFormatter );
+ $changeOp = new ChangeOpQualifier( $claimGuid,
$newQualifier, $params['snakhash'] );
} else {
$propertyId =
$this->claimModificationHelper->getEntityIdFromString( $params['property'] );
$newQualifier =
$this->claimModificationHelper->getSnakInstance( $params, $propertyId );
- $changeOp = new ChangeOpQualifier( $claimGuid,
$newQualifier, '', $idFormatter );
+ $changeOp = new ChangeOpQualifier( $claimGuid,
$newQualifier, '' );
}
return $changeOp;
diff --git a/repo/includes/api/SetStatementRank.php
b/repo/includes/api/SetStatementRank.php
index 731daa4..9ac4856 100644
--- a/repo/includes/api/SetStatementRank.php
+++ b/repo/includes/api/SetStatementRank.php
@@ -98,10 +98,9 @@
$params = $this->extractRequestParams();
$claimGuid = $params['statement'];
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$rank = ClaimSerializer::unserializeRank( $params['rank'] );
- $changeOp = new ChangeOpStatementRank( $claimGuid, $rank,
$idFormatter );
+ $changeOp = new ChangeOpStatementRank( $claimGuid, $rank );
return $changeOp;
}
diff --git a/repo/includes/changeop/ChangeOpMainSnak.php
b/repo/includes/changeop/ChangeOpMainSnak.php
index bbc2a25..2009dd3 100644
--- a/repo/includes/changeop/ChangeOpMainSnak.php
+++ b/repo/includes/changeop/ChangeOpMainSnak.php
@@ -5,7 +5,6 @@
use InvalidArgumentException;
use Wikibase\Lib\ClaimGuidGenerator;
use Wikibase\Snak;
-use Wikibase\Lib\EntityIdFormatter;
/**
* Class for mainsnak change operation
@@ -32,24 +31,16 @@
protected $snak;
/**
- * @since 0.4
- *
- * @var EntityIdFormatter
- */
- protected $idFormatter;
-
- /**
* Constructs a new mainsnak change operation
*
* @since 0.4
*
* @param string $claimGuid
* @param Snak|null $snak
- * @param Lib\EntityIdFormatter $idFormatter
* @param Lib\ClaimGuidGenerator $guidGenerator
* @throws \InvalidArgumentException
*/
- public function __construct( $claimGuid, $snak, EntityIdFormatter
$idFormatter, ClaimGuidGenerator $guidGenerator ) {
+ public function __construct( $claimGuid, $snak, ClaimGuidGenerator
$guidGenerator ) {
if ( !is_string( $claimGuid ) ) {
throw new InvalidArgumentException( '$claimGuid needs
to be a string' );
}
@@ -64,7 +55,6 @@
$this->claimGuid = $claimGuid;
$this->snak = $snak;
- $this->idFormatter = $idFormatter;
$this->guidGenerator = $guidGenerator;
}
@@ -153,16 +143,7 @@
* @return array
*/
protected function getClaimSummaryArgs( Snak $mainSnak ) {
- $propertyId = $this->idFormatter->format(
$mainSnak->getPropertyId() );
-
- //TODO: use formatters here!
- if ( $mainSnak instanceof PropertyValueSnak ) {
- $value = $mainSnak->getDataValue();
- } else {
- $value = $mainSnak->getType();
- }
-
- $args = array( $propertyId => array( $value ) );
- return array( $args );
+ $propertyId = $mainSnak->getPropertyId();
+ return array( $propertyId, $mainSnak );
}
}
diff --git a/repo/includes/changeop/ChangeOpQualifier.php
b/repo/includes/changeop/ChangeOpQualifier.php
index 86b6f6b..f4565ba 100644
--- a/repo/includes/changeop/ChangeOpQualifier.php
+++ b/repo/includes/changeop/ChangeOpQualifier.php
@@ -10,24 +10,7 @@
/**
* Class for qualifier change operation
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
* @since 0.4
- *
- * @ingroup WikibaseRepo
*
* @licence GNU GPL v2+
* @author Tobias Gritschacher < [email protected] >
@@ -56,13 +39,6 @@
protected $snakHash;
/**
- * @since 0.4
- *
- * @var EntityIdFormatter
- */
- protected $idFormatter;
-
- /**
* Constructs a new qualifier change operation
*
* @since 0.4
@@ -70,11 +46,10 @@
* @param string $claimGuid
* @param Snak|null $snak
* @param string $snakHash
- * @param EntityIdFormatter $entityIdFormatter
*
* @throws InvalidArgumentException
*/
- public function __construct( $claimGuid, $snak, $snakHash,
EntityIdFormatter $idFormatter ) {
+ public function __construct( $claimGuid, $snak, $snakHash ) {
if ( !is_string( $claimGuid ) || $claimGuid === '' ) {
throw new InvalidArgumentException( '$claimGuid needs
to be a string and must not be empty' );
}
@@ -94,7 +69,6 @@
$this->claimGuid = $claimGuid;
$this->snak = $snak;
$this->snakHash = $snakHash;
- $this->idFormatter = $idFormatter;
}
/**
@@ -189,20 +163,9 @@
* @param Snak $mainSnak
*
* @return array
- *
- * @todo: REUSE!!
*/
protected function getSnakSummaryArgs( Snak $snak ) {
- $propertyId = $this->idFormatter->format(
$snak->getPropertyId() );
-
- //TODO: use formatters here!
- if ( $snak instanceof PropertyValueSnak ) {
- $value = $snak->getDataValue();
- } else {
- $value = $snak->getType();
- }
-
- $args = array( $propertyId => array( $value ) );
- return array( $args );
+ $propertyId = $snak->getPropertyId();
+ return array( $propertyId, $snak );
}
}
diff --git a/repo/includes/changeop/ChangeOpReference.php
b/repo/includes/changeop/ChangeOpReference.php
index b56df8e..f1f07a1 100644
--- a/repo/includes/changeop/ChangeOpReference.php
+++ b/repo/includes/changeop/ChangeOpReference.php
@@ -12,24 +12,7 @@
/**
* Class for reference change operation
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
* @since 0.4
- *
- * @ingroup WikibaseRepo
*
* @licence GNU GPL v2+
* @author Tobias Gritschacher < [email protected] >
@@ -58,13 +41,6 @@
protected $referenceHash;
/**
- * @since 0.4
- *
- * @var EntityIdFormatter
- */
- protected $idFormatter;
-
- /**
* Constructs a new reference change operation
*
* @since 0.4
@@ -72,11 +48,10 @@
* @param string $claimGuid
* @param Reference|null $reference
* @param string $referenceHash
- * @param EntityIdFormatter $entityIdFormatter
*
* @throws InvalidArgumentException
*/
- public function __construct( $claimGuid, $reference, $referenceHash,
EntityIdFormatter $idFormatter ) {
+ public function __construct( $claimGuid, $reference, $referenceHash ) {
if ( !is_string( $claimGuid ) || $claimGuid === '' ) {
throw new InvalidArgumentException( '$claimGuid needs
to be a string and must not be empty' );
}
@@ -96,7 +71,6 @@
$this->claimGuid = $claimGuid;
$this->reference = $reference;
$this->referenceHash = $referenceHash;
- $this->idFormatter = $idFormatter;
}
/**
@@ -203,20 +177,10 @@
* @param Reference $reference
*
* @return array
- *
- * @todo: REUSE!!
*/
protected function getSnakSummaryArgs( Snak $snak ) {
- $propertyId = $this->idFormatter->format(
$snak->getPropertyId() );
+ $propertyId = $snak->getPropertyId();
- //TODO: use formatters here!
- if ( $snak instanceof PropertyValueSnak ) {
- $value = $snak->getDataValue();
- } else {
- $value = $snak->getType();
- }
-
- $args = array( $propertyId => array( $value ) );
- return array( $args );
+ return array( $propertyId, $snak );
}
}
diff --git a/repo/includes/changeop/ChangeOpStatementRank.php
b/repo/includes/changeop/ChangeOpStatementRank.php
index 75527ff..008d78e 100644
--- a/repo/includes/changeop/ChangeOpStatementRank.php
+++ b/repo/includes/changeop/ChangeOpStatementRank.php
@@ -11,24 +11,7 @@
/**
* Class for statement rank change operation
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
* @since 0.4
- *
- * @ingroup WikibaseRepo
*
* @licence GNU GPL v2+
* @author Tobias Gritschacher < [email protected] >
@@ -50,24 +33,16 @@
protected $rank;
/**
- * @since 0.4
- *
- * @var EntityIdFormatter
- */
- protected $idFormatter;
-
- /**
* Constructs a new statement rank change operation
*
* @since 0.4
*
* @param string $claimGuid
* @param integer $rank
- * @param EntityIdFormatter $entityIdFormatter
*
* @throws InvalidArgumentException
*/
- public function __construct( $claimGuid, $rank, EntityIdFormatter
$idFormatter ) {
+ public function __construct( $claimGuid, $rank ) {
if ( !is_string( $claimGuid ) ) {
throw new InvalidArgumentException( '$claimGuid needs
to be a string' );
}
@@ -78,7 +53,6 @@
$this->claimGuid = $claimGuid;
$this->rank = $rank;
- $this->idFormatter = $idFormatter;
}
/**
@@ -118,20 +92,10 @@
* @param Snak $mainSnak
*
* @return array
- *
- * @todo: REUSE!!
*/
protected function getSnakSummaryArgs( Snak $snak ) {
- $propertyId = $this->idFormatter->format(
$snak->getPropertyId() );
+ $propertyId = $snak->getPropertyId();
- //TODO: use formatters here!
- if ( $snak instanceof PropertyValueSnak ) {
- $value = $snak->getDataValue();
- } else {
- $value = $snak->getType();
- }
-
- $args = array( $propertyId => array( $value ) );
- return array( $args );
+ return array( $propertyId, $snak );
}
}
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
b/repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
index 0c60f64..2c10ae0 100644
--- a/repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpMainSnakTest.php
@@ -28,18 +28,17 @@
public function invalidArgumentProvider() {
$item = ItemContent::newFromArray( array( 'entity' => 'q42' )
)->getEntity();
- $validIdFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$validGuidGenerator = new ClaimGuidGenerator( $item->getId() );
$guidGenerator = new \Wikibase\Lib\ClaimGuidGenerator(
$item->getId() );
$validClaimGuid = $guidGenerator->newGuid();
$validSnak = new \Wikibase\PropertyValueSnak( 7201010, new
\DataValues\StringValue( 'o_O' ) );
$args = array();
- $args[] = array( 123, $validSnak, $validIdFormatter,
$validGuidGenerator );
- $args[] = array( 123, null, $validIdFormatter,
$validGuidGenerator );
- $args[] = array( $validClaimGuid, 'notASnak',
$validIdFormatter, $validGuidGenerator );
- $args[] = array( '', 'notASnak', $validIdFormatter,
$validGuidGenerator );
- $args[] = array( '', null, $validIdFormatter,
$validGuidGenerator );
+ $args[] = array( 123, $validSnak, $validGuidGenerator );
+ $args[] = array( 123, null, $validGuidGenerator );
+ $args[] = array( $validClaimGuid, 'notASnak',
$validGuidGenerator );
+ $args[] = array( '', 'notASnak', $validGuidGenerator );
+ $args[] = array( '', null, $validGuidGenerator );
return $args;
}
@@ -49,19 +48,18 @@
*
* @expectedException InvalidArgumentException
*/
- public function testInvalidConstruct( $claimGuid, $snak, $idFormatter,
$guidGenerator ) {
- $ChangeOpMainSnak = new ChangeOpMainSnak( $claimGuid, $snak,
$idFormatter, $guidGenerator );
+ public function testInvalidConstruct( $claimGuid, $snak, $guidGenerator
) {
+ $ChangeOpMainSnak = new ChangeOpMainSnak( $claimGuid, $snak,
$guidGenerator );
}
public function changeOpProvider() {
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$snak = new \Wikibase\PropertyValueSnak( 2754236, new
\DataValues\StringValue( 'test' ) );
$args = array();
$item = $this->provideNewItemWithClaim( 'q123', $snak );
$newSnak = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'newSnak' ) );
$claimGuid = '';
- $changeOp = new ChangeOpMainSnak( $claimGuid, $newSnak,
$idFormatter, new ClaimGuidGenerator( $item->getId() ) );
+ $changeOp = new ChangeOpMainSnak( $claimGuid, $newSnak, new
ClaimGuidGenerator( $item->getId() ) );
$expected = $newSnak->getDataValue();
$args[] = array ( $item, $changeOp, $expected );
@@ -69,14 +67,14 @@
$newSnak = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'changedSnak' ) );
$claims = $item->getClaims();
$claimGuid = $claims[0]->getGuid();
- $changeOp = new ChangeOpMainSnak( $claimGuid, $newSnak,
$idFormatter, new ClaimGuidGenerator( $item->getId() ) );
+ $changeOp = new ChangeOpMainSnak( $claimGuid, $newSnak, new
ClaimGuidGenerator( $item->getId() ) );
$expected = $newSnak->getDataValue();
$args[] = array ( $item, $changeOp, $expected );
$item = $this->provideNewItemWithClaim( 'q345', $snak );
$claims = $item->getClaims();
$claimGuid = $claims[0]->getGuid();
- $changeOp = new ChangeOpMainSnak( $claimGuid, null,
$idFormatter, new ClaimGuidGenerator( $item->getId() ) );
+ $changeOp = new ChangeOpMainSnak( $claimGuid, null, new
ClaimGuidGenerator( $item->getId() ) );
$expected = null;
$args[] = array ( $item, $changeOp, $expected );
@@ -107,11 +105,10 @@
$item = $this->provideNewItemWithClaim( 'q777', $snak );
$claims = $item->getClaims();
$claimGuid = $claims[0]->getGuid();
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$guidGenerator = new ClaimGuidGenerator( $item->getId() );
- $args[] = array ( new ChangeOpMainSnak( $claimGuid, $newSnak,
$idFormatter, $guidGenerator ) );
- $args[] = array ( new ChangeOpMainSnak( $claimGuid, null,
$idFormatter, $guidGenerator ) );
+ $args[] = array ( new ChangeOpMainSnak( $claimGuid, $newSnak,
$guidGenerator ) );
+ $args[] = array ( new ChangeOpMainSnak( $claimGuid, null,
$guidGenerator ) );
return $args;
}
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpQualifierTest.php
b/repo/tests/phpunit/includes/changeop/ChangeOpQualifierTest.php
index fce3cec..c9a561e 100644
--- a/repo/tests/phpunit/includes/changeop/ChangeOpQualifierTest.php
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpQualifierTest.php
@@ -27,20 +27,19 @@
public function invalidArgumentProvider() {
$item = ItemContent::newFromArray( array( 'entity' => 'q42' )
)->getEntity();
- $validIdFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$guidGenerator = new \Wikibase\Lib\ClaimGuidGenerator(
$item->getId() );
$validClaimGuid = $guidGenerator->newGuid();
$validSnak = new \Wikibase\PropertyValueSnak( 7201010, new
\DataValues\StringValue( 'o_O' ) );
$validSnakHash = $validSnak->getHash();
$args = array();
- $args[] = array( 123, $validSnak, $validSnakHash,
$validIdFormatter );
- $args[] = array( '', $validSnak, $validSnakHash,
$validIdFormatter );
- $args[] = array( 123, null, $validSnakHash, $validIdFormatter );
- $args[] = array( $validClaimGuid, 'notASnak', $validSnakHash,
$validIdFormatter );
- $args[] = array( $validClaimGuid, 'notASnak', '',
$validIdFormatter );
- $args[] = array( $validClaimGuid, null, '', $validIdFormatter );
- $args[] = array( $validClaimGuid, $validSnak, 123,
$validIdFormatter );
+ $args[] = array( 123, $validSnak, $validSnakHash );
+ $args[] = array( '', $validSnak, $validSnakHash );
+ $args[] = array( 123, null, $validSnakHash );
+ $args[] = array( $validClaimGuid, 'notASnak', $validSnakHash );
+ $args[] = array( $validClaimGuid, 'notASnak', '' );
+ $args[] = array( $validClaimGuid, null, '' );
+ $args[] = array( $validClaimGuid, $validSnak, 123 );
return $args;
}
@@ -50,12 +49,11 @@
*
* @expectedException InvalidArgumentException
*/
- public function testInvalidConstruct( $claimGuid, $snak, $snakHash,
$idFormatter ) {
- $ChangeOpQualifier = new ChangeOpQualifier( $claimGuid, $snak,
$snakHash, $idFormatter );
+ public function testInvalidConstruct( $claimGuid, $snak, $snakHash ) {
+ $ChangeOpQualifier = new ChangeOpQualifier( $claimGuid, $snak,
$snakHash );
}
public function changeOpAddProvider() {
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$snak = new \Wikibase\PropertyValueSnak( 2754236, new
\DataValues\StringValue( 'test' ) );
$args = array();
@@ -63,7 +61,7 @@
$claims = $item->getClaims();
$claimGuid = $claims[0]->getGuid();
$newQualifier = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'newQualifier' ) );
- $changeOp = new ChangeOpQualifier( $claimGuid, $newQualifier,
'', $idFormatter );
+ $changeOp = new ChangeOpQualifier( $claimGuid, $newQualifier,
'' );
$snakHash = $newQualifier->getHash();
$args[] = array ( $item, $changeOp, $snakHash );
@@ -85,7 +83,6 @@
}
public function changeOpRemoveProvider() {
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$snak = new \Wikibase\PropertyValueSnak( 2754236, new
\DataValues\StringValue( 'test' ) );
$args = array();
@@ -98,7 +95,7 @@
$claims[0]->setQualifiers( $qualifiers );
$item->setClaims( new Claims( $claims ) );
$snakHash = $newQualifier->getHash();
- $changeOp = new ChangeOpQualifier( $claimGuid, null, $snakHash,
$idFormatter );
+ $changeOp = new ChangeOpQualifier( $claimGuid, null, $snakHash
);
$args[] = array ( $item, $changeOp, $snakHash );
return $args;
@@ -119,7 +116,6 @@
}
public function changeOpSetProvider() {
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$snak = new \Wikibase\PropertyValueSnak( 2754236, new
\DataValues\StringValue( 'test' ) );
$args = array();
@@ -133,7 +129,7 @@
$item->setClaims( new Claims( $claims ) );
$snakHash = $newQualifier->getHash();
$changedQualifier = new \Wikibase\PropertyValueSnak( 78462378,
new \DataValues\StringValue( 'changedQualifier' ) );
- $changeOp = new ChangeOpQualifier( $claimGuid,
$changedQualifier, $snakHash, $idFormatter );
+ $changeOp = new ChangeOpQualifier( $claimGuid,
$changedQualifier, $snakHash );
$args[] = array ( $item, $changeOp,
$changedQualifier->getHash() );
return $args;
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpReferenceTest.php
b/repo/tests/phpunit/includes/changeop/ChangeOpReferenceTest.php
index 165ca09..4a4d382 100644
--- a/repo/tests/phpunit/includes/changeop/ChangeOpReferenceTest.php
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpReferenceTest.php
@@ -28,7 +28,6 @@
public function invalidArgumentProvider() {
$item = ItemContent::newFromArray( array( 'entity' => 'q42' )
)->getEntity();
- $validIdFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$guidGenerator = new \Wikibase\Lib\ClaimGuidGenerator(
$item->getId() );
$validClaimGuid = $guidGenerator->newGuid();
$snaks = new SnakList();
@@ -37,13 +36,13 @@
$validReferenceHash = $validReference->getHash();
$args = array();
- $args[] = array( 123, $validReference, $validReferenceHash,
$validIdFormatter );
- $args[] = array( '', $validReference, $validReferenceHash,
$validIdFormatter );
- $args[] = array( '', null, $validReferenceHash,
$validIdFormatter );
- $args[] = array( $validClaimGuid, $validReference, 123,
$validIdFormatter );
- $args[] = array( $validClaimGuid, 'notAReference',
$validReferenceHash, $validIdFormatter );
- $args[] = array( $validClaimGuid, 'notAReference', '',
$validIdFormatter );
- $args[] = array( $validClaimGuid, null, '', $validIdFormatter );
+ $args[] = array( 123, $validReference, $validReferenceHash );
+ $args[] = array( '', $validReference, $validReferenceHash );
+ $args[] = array( '', null, $validReferenceHash );
+ $args[] = array( $validClaimGuid, $validReference, 123 );
+ $args[] = array( $validClaimGuid, 'notAReference',
$validReferenceHash );
+ $args[] = array( $validClaimGuid, 'notAReference', '' );
+ $args[] = array( $validClaimGuid, null, '' );
return $args;
}
@@ -53,12 +52,11 @@
*
* @expectedException InvalidArgumentException
*/
- public function testInvalidConstruct( $claimGuid, $reference,
$referenceHash, $idFormatter ) {
- $ChangeOpQualifier = new ChangeOpReference( $claimGuid,
$reference, $referenceHash, $idFormatter );
+ public function testInvalidConstruct( $claimGuid, $reference,
$referenceHash ) {
+ $ChangeOpQualifier = new ChangeOpReference( $claimGuid,
$reference, $referenceHash );
}
public function changeOpAddProvider() {
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$snak = new \Wikibase\PropertyValueSnak( 2754236, new
\DataValues\StringValue( 'test' ) );
$args = array();
@@ -68,7 +66,7 @@
$snaks = new SnakList();
$snaks[] = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'newQualifier' ) );
$newReference = new Reference( $snaks );
- $changeOp = new ChangeOpReference( $claimGuid, $newReference,
'', $idFormatter );
+ $changeOp = new ChangeOpReference( $claimGuid, $newReference,
'' );
$referenceHash = $newReference->getHash();
$args[] = array ( $item, $changeOp, $referenceHash );
@@ -90,7 +88,6 @@
}
public function changeOpRemoveProvider() {
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$snak = new \Wikibase\PropertyValueSnak( 2754236, new
\DataValues\StringValue( 'test' ) );
$args = array();
@@ -105,7 +102,7 @@
$claims[0]->setReferences( $references );
$item->setClaims( new Claims( $claims ) );
$referenceHash = $newReference->getHash();
- $changeOp = new ChangeOpReference( $claimGuid, null,
$referenceHash, $idFormatter );
+ $changeOp = new ChangeOpReference( $claimGuid, null,
$referenceHash );
$args[] = array ( $item, $changeOp, $referenceHash );
return $args;
@@ -126,7 +123,6 @@
}
public function changeOpSetProvider() {
- $idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$snak = new \Wikibase\PropertyValueSnak( 2754236, new
\DataValues\StringValue( 'test' ) );
$args = array();
@@ -144,7 +140,7 @@
$snaks = new SnakList();
$snaks[] = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'changedQualifier' ) );
$changedReference = new Reference( $snaks );
- $changeOp = new ChangeOpReference( $claimGuid,
$changedReference, $referenceHash, $idFormatter );
+ $changeOp = new ChangeOpReference( $claimGuid,
$changedReference, $referenceHash );
$args[] = array ( $item, $changeOp,
$changedReference->getHash() );
return $args;
diff --git a/repo/tests/phpunit/includes/changeop/ChangeOpStatementRankTest.php
b/repo/tests/phpunit/includes/changeop/ChangeOpStatementRankTest.php
index 9a86091..5462dbd 100644
--- a/repo/tests/phpunit/includes/changeop/ChangeOpStatementRankTest.php
+++ b/repo/tests/phpunit/includes/changeop/ChangeOpStatementRankTest.php
@@ -27,14 +27,13 @@
public function invalidArgumentProvider() {
$item = ItemContent::newFromArray( array( 'entity' => 'q42' )
)->getEntity();
- $validIdFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$guidGenerator = new \Wikibase\Lib\ClaimGuidGenerator(
$item->getId() );
$validClaimGuid = $guidGenerator->newGuid();
$validRank = 1;
$args = array();
- $args[] = array( 123, $validRank, $validIdFormatter );
- $args[] = array( $validClaimGuid, ':-)', $validIdFormatter );
+ $args[] = array( 123, $validRank );
+ $args[] = array( $validClaimGuid, ':-)' );
return $args;
}
@@ -44,8 +43,8 @@
*
* @expectedException InvalidArgumentException
*/
- public function testInvalidConstruct( $claimGuid, $rank, $idFormatter )
{
- $ChangeOpStatementRank = new ChangeOpStatementRank( $claimGuid,
$rank, $idFormatter );
+ public function testInvalidConstruct( $claimGuid, $rank ) {
+ $ChangeOpStatementRank = new ChangeOpStatementRank( $claimGuid,
$rank );
}
public function changeOpProvider() {
@@ -58,7 +57,7 @@
$claimGuid = $claims[0]->getGuid();
$rank = 1;
- $changeOp = new ChangeOpStatementRank( $claimGuid, $rank,
$idFormatter );
+ $changeOp = new ChangeOpStatementRank( $claimGuid, $rank );
$args[] = array ( $item, $changeOp, $rank );
--
To view, visit https://gerrit.wikimedia.org/r/84975
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3cd556c871a0f641bbf0a010118566bedd7da998
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits