Skip to content

Commit

Permalink
Change construction of Statement with a Snak parameter.
Browse files Browse the repository at this point in the history
In WikibaseDataModel 2.0 it is not directly supported anymore thus wrap it in a
Claim.
  • Loading branch information
JanZerebecki committed Oct 15, 2014
1 parent f3b128d commit 87f4f66
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
3 changes: 1 addition & 2 deletions src/Deserializers/LegacyClaimDeserializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ private function getClaim() {

private function getStatement() {
$statement = new Statement(
$this->getMainSnak(),
$this->getQualifiers(),
new Claim( $this->getMainSnak(), $this->getQualifiers() ),
$this->getReferences()
);

Expand Down
3 changes: 1 addition & 2 deletions src/Deserializers/LegacyStatementDeserializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ private function newStatement() {

private function newStatementFromClaim( Claim $claim ) {
$statement = new Statement(
$claim->getMainSnak(),
$claim->getQualifiers()
new Claim( $claim->getMainSnak(), $claim->getQualifiers() )
);

$statement->setGuid( $claim->getGuid() );
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/Deserializers/LegacyClaimDeserializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,13 @@ public function testGivenValidSerialization_deserializeReturnsComplexClaim() {

public function testGivenValidSerialization_deserializeReturnsStatement() {
$statement = new Statement(
new PropertyNoValueSnak( 42 ),
new SnakList( array(
new PropertyNoValueSnak( 23 ),
new PropertyNoValueSnak( 1337 ),
) ),
new Claim(
new PropertyNoValueSnak( 42 ),
new SnakList( array(
new PropertyNoValueSnak( 23 ),
new PropertyNoValueSnak( 1337 ),
) )
),
new ReferenceList( array(
new Reference(
new SnakList( array(
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Deserializers/LegacyItemDeserializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function testGivenStatement_itemHasStatement() {
}

private function newStatement() {
$statement = new Statement( new PropertyNoValueSnak( 42 ) );
$statement = new Statement( new Claim( new PropertyNoValueSnak( 42 ) ) );
$statement->setGuid( 'foo' );
return $statement;
}
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/Deserializers/LegacyStatementDeserializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ public function testGivenInvalidSerialization_deserializeThrowsException( $seria

public function testGivenValidSerialization_deserializeReturnsStatement() {
$statement = new Statement(
new PropertyNoValueSnak( 42 ),
new SnakList( array(
new PropertyNoValueSnak( 23 ),
new PropertyNoValueSnak( 1337 ),
) ),
new Claim(
new PropertyNoValueSnak( 42 ),
new SnakList( array(
new PropertyNoValueSnak( 23 ),
new PropertyNoValueSnak( 1337 ),
) )
),
new ReferenceList( array(
new Reference(
new SnakList( array(
Expand Down

0 comments on commit 87f4f66

Please sign in to comment.