Daniel Kinzler has uploaded a new change for review.
https://gerrit.wikimedia.org/r/89016
Change subject: (bug #55569) Fix tests after Claims no longer use hashes.
......................................................................
(bug #55569) Fix tests after Claims no longer use hashes.
Change-Id: I3dd0dedf114a339eba4fc8c574c5713735a52135
IMPORTANT: requires Idd5ffb72774a948852a6d
---
M
client/tests/phpunit/includes/parserhooks/PropertyParserFunctionRendererTest.php
M lib/tests/phpunit/changes/TestChanges.php
M lib/tests/phpunit/serializers/ClaimsSerializerTest.php
M lib/tests/phpunit/serializers/SerializerBaseTest.php
M repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.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
M repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php
M repo/tests/phpunit/includes/EntityViewTest.php
11 files changed, 150 insertions(+), 93 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/16/89016/1
diff --git
a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionRendererTest.php
b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionRendererTest.php
index ba78be0..3a260df 100644
---
a/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionRendererTest.php
+++
b/client/tests/phpunit/includes/parserhooks/PropertyParserFunctionRendererTest.php
@@ -59,16 +59,22 @@
$entityLookup = new MockRepository();
- $item = Item::newEmpty();
- $item->setId( 42 );
- $item->addClaim( new Claim( new PropertyValueSnak(
+ $claim1 = new Claim( new PropertyValueSnak(
$propertyId,
new StringValue( 'Please write tests before merging
your code' )
- ) ) );
- $item->addClaim( new Claim( new PropertyValueSnak(
+ ) );
+ $claim1->setGuid( __METHOD__ . '$' . 1 );
+
+ $claim2 = new Claim( new PropertyValueSnak(
$propertyId,
new StringValue( 'or kittens will die' )
- ) ) );
+ ) );
+ $claim2->setGuid( __METHOD__ . '$' . 2 );
+
+ $item = Item::newEmpty();
+ $item->setId( 42 );
+ $item->addClaim( $claim1 );
+ $item->addClaim( $claim2 );
$property = Property::newEmpty();
$property->setId( $propertyId );
diff --git a/lib/tests/phpunit/changes/TestChanges.php
b/lib/tests/phpunit/changes/TestChanges.php
index 5d05ffe..32c937c 100644
--- a/lib/tests/phpunit/changes/TestChanges.php
+++ b/lib/tests/phpunit/changes/TestChanges.php
@@ -146,7 +146,7 @@
$propertyId = new EntityId( Property::ENTITY_TYPE, 23 );
$snak = new PropertyNoValueSnak( $propertyId );
$claim = new Claim( $snak );
- $claim->setGuid( 'test-guid' );
+ $claim->setGuid( 'TEST$test-guid' );
$claims = new Claims( array( $claim ) );
$new->setClaims( $claims );
diff --git a/lib/tests/phpunit/serializers/ClaimsSerializerTest.php
b/lib/tests/phpunit/serializers/ClaimsSerializerTest.php
index 3ce5b37..79682b7 100644
--- a/lib/tests/phpunit/serializers/ClaimsSerializerTest.php
+++ b/lib/tests/phpunit/serializers/ClaimsSerializerTest.php
@@ -49,9 +49,13 @@
$claims = array(
new Claim( new PropertyNoValueSnak( $propertyId ) ),
- new Claim( new PropertySomeValueSnak( new PropertyId(
'P1' ) ) ),
new Statement( new PropertyNoValueSnak( $propertyId ) ),
+ new Claim( new PropertySomeValueSnak( new PropertyId(
'P1' ) ) ),
);
+
+ foreach ( $claims as $i => $claim ) {
+ $claim->setGuid( 'ClaimsSerializerTest$claim-' . $i );
+ }
$claimSerializer = new ClaimSerializer();
@@ -60,10 +64,10 @@
array(
'P42' => array(
$claimSerializer->getSerialized(
$claims[0] ),
- $claimSerializer->getSerialized(
$claims[2] ),
+ $claimSerializer->getSerialized(
$claims[1] ),
),
'P1' => array(
- $claimSerializer->getSerialized(
$claims[1] ),
+ $claimSerializer->getSerialized(
$claims[2] ),
),
),
);
diff --git a/lib/tests/phpunit/serializers/SerializerBaseTest.php
b/lib/tests/phpunit/serializers/SerializerBaseTest.php
index 7167ec0..b382d68 100644
--- a/lib/tests/phpunit/serializers/SerializerBaseTest.php
+++ b/lib/tests/phpunit/serializers/SerializerBaseTest.php
@@ -94,13 +94,14 @@
protected function assertMeaningfulEquals( $expected, $actual, $message
= '' ) {
if ( is_object( $expected ) ) {
if ( $expected instanceof Comparable ) {
+ $this->assertInstanceOf( '\Comparable',
$actual, $message );
$this->assertTrue( $expected->equals( $actual
), $message );
return;
}
if ( $expected instanceof Hashable ) {
$this->assertInstanceOf( '\Hashable', $actual,
$message );
- $this->assertEquals( $expected->getHash(
$actual ), $actual->getHash(), $message );
+ $this->assertEquals( $expected->getHash(),
$actual->getHash(), $message );
return;
}
}
diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.php
b/repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.php
index 9b87503..6b11ff4 100644
--- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.php
+++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpClaimTest.php
@@ -54,21 +54,25 @@
$item777 = self::provideNewItemWithClaim( 777, new
PropertyNoValueSnak( 45 ) );
$item666 = self::provideNewItemWithClaim( 666, new
PropertySomeValueSnak( 44 ) );
+ $item777Claims = $item777->getClaims();
+ $item666Claims = $item666->getClaims();
+
+ $claim777 = reset( $item777Claims );
+ $claim666 = reset( $item666Claims );
+
//claims that exist on the given entities
$claims[0] = new Claim( new PropertyNoValueSnak( 43 ) );
- $item777Claims = $item777->getClaims();
- $claims[777] = clone $item777Claims[0];
- $item666Claims = $item666->getClaims();
- $claims[666] = clone $item666Claims[0];
+ $claims[777] = clone $claim777;
+ $claims[666] = clone $claim666;
//claims with a null guid
- $claims[7770] = clone $item777Claims[0];
+ $claims[7770] = clone $claim777;
$claims[7770]->setGuid( null );
- $claims[6660] = clone $item666Claims[0];
+ $claims[6660] = clone $claim666;
$claims[6660]->setGuid( null );
//new claims not yet on the entity
- $claims[7777] = clone $item777Claims[0];
+ $claims[7777] = clone $claim777;
$claims[7777]->setGuid(
'Q777$D8404CDA-25E4-4334-AF13-A3290BC77777' );
- $claims[6666] = clone $item666Claims[0];
+ $claims[6666] = clone $claim666;
$claims[6666]->setGuid(
'Q666$D8404CDA-25E4-4334-AF13-A3290BC66666' );
$args = array();
@@ -110,9 +114,18 @@
}
$entityClaims = new Claims( $entity->getClaims() );
+ $entityClaimHashSet = array_flip( $entityClaims->getHashes() );
foreach( $expected as $expectedClaim ){
- $this->assertTrue( $entityClaims->hasClaim(
$expectedClaim ) );
+ $guid = $expectedClaim->getGuid();
+ $hash = $expectedClaim->getHash();
+
+ if ( $guid !== null ) {
+ $this->assertTrue(
$entityClaims->hasClaimWithGuid( $guid ) );
+ }
+
+ $this->assertArrayHasKey( $hash, $entityClaimHashSet );
}
+
$this->assertEquals( count( $expected ), $entityClaims->count()
);
}
diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpMainSnakTest.php
b/repo/tests/phpunit/includes/ChangeOp/ChangeOpMainSnakTest.php
index 0faba72..882fb23 100644
--- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpMainSnakTest.php
+++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpMainSnakTest.php
@@ -68,14 +68,16 @@
$item = $this->provideNewItemWithClaim( 'q234', $snak );
$newSnak = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'changedSnak' ) );
$claims = $item->getClaims();
- $claimGuid = $claims[0]->getGuid();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$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();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$changeOp = new ChangeOpMainSnak( $claimGuid, null, new
ClaimGuidGenerator( $item->getId() ) );
$expected = null;
$args[] = array ( $item, $changeOp, $expected );
@@ -106,7 +108,8 @@
$newSnak = new \Wikibase\PropertyValueSnak( 12651236, new
\DataValues\StringValue( 'newww' ) );
$item = $this->provideNewItemWithClaim( 'q777', $snak );
$claims = $item->getClaims();
- $claimGuid = $claims[0]->getGuid();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$guidGenerator = new ClaimGuidGenerator( $item->getId() );
$args[] = array ( new ChangeOpMainSnak( $claimGuid, $newSnak,
$guidGenerator ) );
diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpQualifierTest.php
b/repo/tests/phpunit/includes/ChangeOp/ChangeOpQualifierTest.php
index d95dffa..c8d0c84 100644
--- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpQualifierTest.php
+++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpQualifierTest.php
@@ -59,7 +59,8 @@
$item = $this->provideNewItemWithClaim( 'q123', $snak );
$claims = $item->getClaims();
- $claimGuid = $claims[0]->getGuid();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$newQualifier = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'newQualifier' ) );
$changeOp = new ChangeOpQualifier( $claimGuid, $newQualifier,
'' );
$snakHash = $newQualifier->getHash();
@@ -78,7 +79,8 @@
public function testApplyAddNewQualifier( $item, $changeOp, $snakHash )
{
$this->assertTrue( $changeOp->apply( $item ), "Applying the
ChangeOp did not return true" );
$claims = new Claims( $item->getClaims() );
- $qualifiers = $claims[0]->getQualifiers();
+ $claim = reset( $claims );
+ $qualifiers = $claim->getQualifiers();
$this->assertTrue( $qualifiers->hasSnakHash( $snakHash ), "No
qualifier with expected hash" );
}
@@ -88,11 +90,12 @@
$item = $this->provideNewItemWithClaim( 'q345', $snak );
$claims = $item->getClaims();
- $claimGuid = $claims[0]->getGuid();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$newQualifier = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'newQualifier' ) );
- $qualifiers = $claims[0]->getQualifiers();
+ $qualifiers = $claim->getQualifiers();
$qualifiers->addSnak( $newQualifier );
- $claims[0]->setQualifiers( $qualifiers );
+ $claim->setQualifiers( $qualifiers );
$item->setClaims( new Claims( $claims ) );
$snakHash = $newQualifier->getHash();
$changeOp = new ChangeOpQualifier( $claimGuid, null, $snakHash
);
@@ -111,7 +114,8 @@
public function testApplyRemoveQualifier( $item, $changeOp, $snakHash )
{
$this->assertTrue( $changeOp->apply( $item ), "Applying the
ChangeOp did not return true" );
$claims = new Claims( $item->getClaims() );
- $qualifiers = $claims[0]->getQualifiers();
+ $claim = reset( $claims );
+ $qualifiers = $claim->getQualifiers();
$this->assertFalse( $qualifiers->hasSnakHash( $snakHash ),
"Qualifier still exists" );
}
@@ -121,11 +125,12 @@
$item = $this->provideNewItemWithClaim( 'q123', $snak );
$claims = $item->getClaims();
- $claimGuid = $claims[0]->getGuid();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$newQualifier = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'newQualifier' ) );
- $qualifiers = $claims[0]->getQualifiers();
+ $qualifiers = $claim->getQualifiers();
$qualifiers->addSnak( $newQualifier );
- $claims[0]->setQualifiers( $qualifiers );
+ $claim->setQualifiers( $qualifiers );
$item->setClaims( new Claims( $claims ) );
$snakHash = $newQualifier->getHash();
$changedQualifier = new \Wikibase\PropertyValueSnak( 78462378,
new \DataValues\StringValue( 'changedQualifier' ) );
@@ -145,7 +150,8 @@
public function testApplySetQualifier( $item, $changeOp, $snakHash ) {
$this->assertTrue( $changeOp->apply( $item ), "Applying the
ChangeOp did not return true" );
$claims = new Claims( $item->getClaims() );
- $qualifiers = $claims[0]->getQualifiers();
+ $claim = reset( $claims );
+ $qualifiers = $claim->getQualifiers();
$this->assertTrue( $qualifiers->hasSnakHash( $snakHash ), "No
qualifier with expected hash" );
}
diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpReferenceTest.php
b/repo/tests/phpunit/includes/ChangeOp/ChangeOpReferenceTest.php
index d0d057b..a43ad8a 100644
--- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpReferenceTest.php
+++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpReferenceTest.php
@@ -62,7 +62,8 @@
$item = $this->provideNewItemWithClaim( 'q123', $snak );
$claims = $item->getClaims();
- $claimGuid = $claims[0]->getGuid();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$snaks = new SnakList();
$snaks[] = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'newQualifier' ) );
$newReference = new Reference( $snaks );
@@ -82,8 +83,9 @@
*/
public function testApplyAddNewReference( $item, $changeOp,
$referenceHash ) {
$this->assertTrue( $changeOp->apply( $item ), "Applying the
ChangeOp did not return true" );
- $claims = new Claims( $item->getClaims() );
- $references = $claims[0]->getReferences();
+ $claims = $item->getClaims();
+ $claim = reset( $claims );
+ $references = $claim->getReferences();
$this->assertTrue( $references->hasReferenceHash(
$referenceHash ), "No reference with expected hash" );
}
@@ -93,13 +95,14 @@
$item = $this->provideNewItemWithClaim( 'q345', $snak );
$claims = $item->getClaims();
- $claimGuid = $claims[0]->getGuid();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$snaks = new SnakList();
$snaks[] = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'newQualifier' ) );
$newReference = new Reference( $snaks );
- $references = $claims[0]->getReferences();
+ $references = $claim->getReferences();
$references->addReference( $newReference );
- $claims[0]->setReferences( $references );
+ $claim->setReferences( $references );
$item->setClaims( new Claims( $claims ) );
$referenceHash = $newReference->getHash();
$changeOp = new ChangeOpReference( $claimGuid, null,
$referenceHash );
@@ -117,8 +120,9 @@
*/
public function testApplyRemoveReference( $item, $changeOp,
$referenceHash ) {
$this->assertTrue( $changeOp->apply( $item ), "Applying the
ChangeOp did not return true" );
- $claims = new Claims( $item->getClaims() );
- $references = $claims[0]->getReferences();
+ $claims = $item->getClaims();
+ $claim = reset( $claims );
+ $references = $claim->getReferences();
$this->assertFalse( $references->hasReferenceHash(
$referenceHash ), "Reference still exists" );
}
@@ -128,13 +132,14 @@
$item = $this->provideNewItemWithClaim( 'q123', $snak );
$claims = $item->getClaims();
- $claimGuid = $claims[0]->getGuid();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$snaks = new SnakList();
$snaks[] = new \Wikibase\PropertyValueSnak( 78462378, new
\DataValues\StringValue( 'newQualifier' ) );
$newReference = new Reference( $snaks );
- $references = $claims[0]->getReferences();
+ $references = $claim->getReferences();
$references->addReference( $newReference );
- $claims[0]->setReferences( $references );
+ $claim->setReferences( $references );
$item->setClaims( new Claims( $claims ) );
$referenceHash = $newReference->getHash();
$snaks = new SnakList();
@@ -156,7 +161,8 @@
public function testApplySetReference( $item, $changeOp, $referenceHash
) {
$this->assertTrue( $changeOp->apply( $item ), "Applying the
ChangeOp did not return true" );
$claims = new Claims( $item->getClaims() );
- $references = $claims[0]->getReferences();
+ $claim = reset( $claims );
+ $references = $claim->getReferences();
$this->assertTrue( $references->hasReferenceHash(
$referenceHash ), "No reference with expected hash" );
}
diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpStatementRankTest.php
b/repo/tests/phpunit/includes/ChangeOp/ChangeOpStatementRankTest.php
index a3b45a4..4c563e3 100644
--- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpStatementRankTest.php
+++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpStatementRankTest.php
@@ -54,7 +54,8 @@
$item = $this->provideNewItemWithClaim( 'q123', $snak );
$claims = $item->getClaims();
- $claimGuid = $claims[0]->getGuid();
+ $claim = reset( $claims );
+ $claimGuid = $claim->getGuid();
$rank = 1;
$changeOp = new ChangeOpStatementRank( $claimGuid, $rank );
@@ -73,8 +74,9 @@
*/
public function testApplyStatementRank( $item, $changeOp, $expectedRank
) {
$this->assertTrue( $changeOp->apply( $item ), "Applying the
ChangeOp did not return true" );
- $claims = new Claims( $item->getClaims() );
- $rank = $claims[0]->getRank();
+ $claims = $item->getClaims();
+ $claim = reset( $claims );
+ $rank = $claim->getRank();
$this->assertEquals( $rank, $expectedRank, "No reference with
expected hash" );
}
diff --git a/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php
b/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php
index da32ef4..6e1e73b 100644
--- a/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php
+++ b/repo/tests/phpunit/includes/ChangeOp/ChangeOpsMergeTest.php
@@ -5,6 +5,7 @@
use Wikibase\ChangeOp\ChangeOpsMerge;
use Wikibase\Claims;
use Wikibase\DataModel\Entity\ItemId;
+use Wikibase\DataModel\Internal\ObjectComparer;
use Wikibase\DataModel\SimpleSiteLink;
use Wikibase\Item;
use Wikibase\ItemContent;
@@ -50,29 +51,32 @@
$changeOps->apply();
- //Cycle through thr old claims and set the guids to null (we no
longer know what they should be)
- $fromClaims = new Claims( $from->getEntity()->getClaims() );
- foreach( $from->getEntity()->getClaims() as $claim ) {
- $this->assertStringStartsWith(
-
$from->getEntity()->getId()->getSerialization(), $claim->getGuid(),
- 'FromItem has a claim prefixed with the wrong
guid'
- );
- $fromClaims->removeClaim( $claim );
- $claim->setGuid( null );
- $fromClaims->addClaim( $claim );
- }
- $from->getEntity()->setClaims( $fromClaims );
- $toClaims = new Claims( $to->getEntity()->getClaims() );
- foreach( $to->getEntity()->getClaims() as $claim ) {
- $this->assertStringStartsWith(
$to->getEntity()->getId()->getSerialization(), $claim->getGuid() );
- $toClaims->removeClaim( $claim );
- $claim->setGuid( null );
- $toClaims->addClaim( $claim );
- }
- $to->getEntity()->setClaims( $toClaims );
- $this->assertTrue( $from->getEntity()->equals( new Item(
$expectedFromData ) ) );
- $this->assertTrue( $to->getEntity()->equals( new Item(
$expectedToData ) ) );
+ $fromData = $from->getItem()->toArray();
+ $toData = $to->getItem()->toArray();
+
+ //Cycle through the old claims and set the guids to null (we no
longer know what they should be)
+ $fromClaims = array();
+ foreach( $fromData['claims'] as $claim ) {
+ unset( $claim['g'] );
+ $fromClaims[] = $claim;
+ }
+
+ $toClaims = array();
+ foreach( $toData['claims'] as $claim ) {
+ unset( $claim['g'] );
+ $toClaims[] = $claim;
+ }
+
+ $fromData['claims'] = $fromClaims;
+ $toData['claims'] = $toClaims;
+
+ $fromData = array_intersect_key( $fromData, $expectedFromData );
+ $toData = array_intersect_key( $toData, $expectedToData );
+
+ $comparer = new ObjectComparer();
+ $this->assertTrue( $comparer->dataEquals( $expectedFromData,
$fromData, array( 'entity' ) ) );
+ $this->assertTrue( $comparer->dataEquals( $expectedToData,
$toData, array( 'entity' ) ) );
}
public static function provideData(){
@@ -115,8 +119,7 @@
array( 'claims' => array(
array(
'm' => array( 'novalue', 56 ),
- 'q' => array( ),
- 'g' => null )
+ 'q' => array( ) )
),
),
),
@@ -133,8 +136,7 @@
array( 'claims' => array(
array(
'm' => array( 'novalue', 56 ),
- 'q' => array( array(
'novalue', 56 ) ),
- 'g' => null )
+ 'q' => array( array(
'novalue', 56 ) ) )
),
),
),
@@ -161,8 +163,7 @@
'claims' => array(
array(
'm' => array(
'novalue', 88 ),
- 'q' => array( array(
'novalue', 88 ) ),
- 'g' => null )
+ 'q' => array( array(
'novalue', 88 ) ) )
),
),
),
diff --git a/repo/tests/phpunit/includes/EntityViewTest.php
b/repo/tests/phpunit/includes/EntityViewTest.php
index 2c363cc..a38b068 100644
--- a/repo/tests/phpunit/includes/EntityViewTest.php
+++ b/repo/tests/phpunit/includes/EntityViewTest.php
@@ -25,6 +25,7 @@
use Wikibase\PropertyNoValueSnak;
use Wikibase\PropertySomeValueSnak;
use Wikibase\PropertyValueSnak;
+use Wikibase\Snak;
/**
* @covers Wikibase\EntityView
@@ -157,7 +158,7 @@
public function getHtmlForClaimsProvider() {
$argLists = array();
- $claim = new Claim(
+ $claim = $this->makeClaim(
new PropertyNoValueSnak(
new PropertyId( 'p24' )
)
@@ -228,6 +229,20 @@
}
}
+ protected $guidCounter = 0;
+
+ protected function makeClaim( Snak $mainSnak, $guid = null ) {
+ if ( $guid === null ) {
+ $this->guidCounter++;
+ $guid = 'EntityViewTest$' . $this->guidCounter;
+ }
+
+ $claim = new Claim( $mainSnak );
+ $claim->setGuid( $guid );
+
+ return $claim;
+ }
+
public function getParserOutputLinksProvider() {
$argLists = array();
@@ -243,28 +258,28 @@
array() );
$argLists["PropertyNoValueSnak"] = array(
- array( new Claim( new PropertyNoValueSnak( $p44 ) ) ),
+ array( $this->makeClaim( new PropertyNoValueSnak( $p44
) ) ),
array( $p44 ) );
$argLists["PropertySomeValueSnak"] = array(
- array( new Claim( new PropertySomeValueSnak( $p44 ) ) ),
+ array( $this->makeClaim( new PropertySomeValueSnak(
$p44 ) ) ),
array( $p44 ) );
$argLists["PropertyValueSnak with string value"] = array(
- array( new Claim( new PropertyValueSnak( $p23, new
StringValue( 'onoez' ) ) ) ),
+ array( $this->makeClaim( new PropertyValueSnak( $p23,
new StringValue( 'onoez' ) ) ) ),
array( $p23 ) );
$argLists["PropertyValueSnak with EntityId"] = array(
- array( new Claim( new PropertyValueSnak( $p44, new
EntityIdValue( $q23 ) ) ) ),
+ array( $this->makeClaim( new PropertyValueSnak( $p44,
new EntityIdValue( $q23 ) ) ) ),
array( $p44, $q23 ) );
$argLists["Mixed Snaks"] = array(
array(
- new Claim( new PropertyValueSnak( $p11, new
EntityIdValue( $q23 ) ) ),
- new Claim( new PropertyNoValueSnak( $p44 ) ),
- new Claim( new PropertySomeValueSnak( $p44 ) ),
- new Claim( new PropertyValueSnak( $p44, new
StringValue( 'onoez' ) ) ),
- new Claim( new PropertyValueSnak( $p44, new
EntityIdValue( $q24 ) ) ),
+ $this->makeClaim( new PropertyValueSnak( $p11,
new EntityIdValue( $q23 ) ) ),
+ $this->makeClaim( new PropertyNoValueSnak( $p44
) ),
+ $this->makeClaim( new PropertySomeValueSnak(
$p44 ) ),
+ $this->makeClaim( new PropertyValueSnak( $p44,
new StringValue( 'onoez' ) ) ),
+ $this->makeClaim( new PropertyValueSnak( $p44,
new EntityIdValue( $q24 ) ) ),
),
array( $p11, $q23, $p44, $q24 ) );
@@ -304,19 +319,19 @@
array() );
$argLists["PropertyNoValueSnak"] = array(
- array( new Claim( new PropertyNoValueSnak( $p42 ) ) ),
+ array( $this->makeClaim( new PropertyNoValueSnak( $p42
) ) ),
array());
$argLists["PropertySomeValueSnak"] = array(
- array( new Claim( new PropertySomeValueSnak( $p42 ) ) ),
+ array( $this->makeClaim( new PropertySomeValueSnak(
$p42 ) ) ),
array() );
$argLists["PropertyValueSnak with string value"] = array(
- array( new Claim( new PropertyValueSnak( $p23, new
StringValue( 'http://not/a/url' ) ) ) ),
+ array( $this->makeClaim( new PropertyValueSnak( $p23,
new StringValue( 'http://not/a/url' ) ) ) ),
array() );
$argLists["PropertyValueSnak with URL"] = array(
- array( new Claim( new PropertyValueSnak( $p42, new
StringValue( 'http://acme.com/test' ) ) ) ),
+ array( $this->makeClaim( new PropertyValueSnak( $p42,
new StringValue( 'http://acme.com/test' ) ) ) ),
array( 'http://acme.com/test' ) );
return $argLists;
@@ -401,7 +416,7 @@
$p11 = new PropertyId( 'p11' );
- $entity->addClaim( new Claim( new PropertyValueSnak( $p11, new
EntityIdValue( $q98 ) ) ) );
+ $entity->addClaim( $this->makeClaim( new PropertyValueSnak(
$p11, new EntityIdValue( $q98 ) ) ) );
$revision = new EntityRevision( $entity, 1234567,
'20130505333333' );
@@ -413,7 +428,7 @@
'wbEntityType' => 'item',
'wbDataLangName' => 'français',
'wbEntityId' => 'Q27449',
- 'wbEntity' =>
'{"id":"Q27449","type":"item","labels":{"de":{"language":"de","value":"foo"},"fr":{"language":"de","value":"foo"}},"claims":{"P11":[{"id":null,"mainsnak":{"snaktype":"value","property":"P11","datavalue":{"value":{"entity-type":"item","numeric-id":27498},"type":"wikibase-entityid"}},"type":"claim"}]}}',
+ 'wbEntity' =>
'{"id":"Q27449","type":"item","labels":{"de":{"language":"de","value":"foo"},"fr":{"language":"de","value":"foo"}},"claims":{"P11":[{"id":"EntityViewTest$1","mainsnak":{"snaktype":"value","property":"P11","datavalue":{"value":{"entity-type":"item","numeric-id":27498},"type":"wikibase-entityid"}},"type":"claim"}]}}',
'wbUsedEntities' =>
'{"Q27498":{"content":{"id":"Q27498","type":"item","labels":{"fr":{"language":"de","value":"bar"}}},"title":"'
. $titleText . '","revision":""}}',
) );
@@ -425,7 +440,7 @@
'wbEntityType' => 'item',
'wbDataLangName' => 'Nederlands',
'wbEntityId' => 'Q27449',
- 'wbEntity' =>
'{"id":"Q27449","type":"item","labels":{"de":{"language":"de","value":"foo"}},"claims":{"P11":[{"id":null,"mainsnak":{"snaktype":"value","property":"P11","datavalue":{"value":{"entity-type":"item","numeric-id":27498},"type":"wikibase-entityid"}},"type":"claim"}]}}',
+ 'wbEntity' =>
'{"id":"Q27449","type":"item","labels":{"de":{"language":"de","value":"foo"}},"claims":{"P11":[{"id":"EntityViewTest$1","mainsnak":{"snaktype":"value","property":"P11","datavalue":{"value":{"entity-type":"item","numeric-id":27498},"type":"wikibase-entityid"}},"type":"claim"}]}}',
'wbUsedEntities' =>
'{"Q27498":{"content":{"id":"Q27498","type":"item"},"title":"' . $titleText .
'","revision":""}}',
) );
--
To view, visit https://gerrit.wikimedia.org/r/89016
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I3dd0dedf114a339eba4fc8c574c5713735a52135
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