Skip to content

Commit

Permalink
Merge pull request #39 from wmde/upgrade-dm
Browse files Browse the repository at this point in the history
Upgrade to data-model 2.0 and release
  • Loading branch information
filbertkm committed Oct 15, 2014
2 parents 73c0d2d + c8af909 commit c05ebf0
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 18 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ Wikibase Internal Serialization has been written by [Jeroen De Dauw]

## Release notes

### 1.3.0 (2014-10-15)

* Compatibility with DataModel 2.x added

### 1.2.1 (2014-09-11)
* Added LegacyStatementDeserializer
* Adding normalization in LegacyItemDeserializer to handle Claims (e.g. no ranks),
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"require": {
"php": ">=5.3.0",
"wikibase/data-model": "~1.0",
"wikibase/data-model": "~2.0|~1.0",
"wikibase/data-model-serialization": "~1.1",
"serialization/serialization": "~3.0"
},
Expand Down
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
4 changes: 2 additions & 2 deletions src/Deserializers/LegacyEntityIdDeserializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Wikibase\DataModel\Entity\EntityId;
use Wikibase\DataModel\Entity\EntityIdParser;
use Wikibase\DataModel\Entity\EntityIdParsingException;
use Wikibase\DataModel\Internal\LegacyIdInterpreter;
use Wikibase\DataModel\LegacyIdInterpreter;

/**
* @licence GNU GPL v2+
Expand Down Expand Up @@ -63,4 +63,4 @@ private function getIdFromLegacyFormat( array $serialization ) {
}
}

}
}
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 c05ebf0

Please sign in to comment.