Skip to content

Commit bde7acf

Browse files
committed
Merge pull request #393 from wmde/master
Merge master into 3.0.x-dev
2 parents cfd61e4 + aee1243 commit bde7acf

12 files changed

Lines changed: 82 additions & 44 deletions

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ via TravisCI, as a TravisCI configuration file is also provided in the root dire
6464
### Development
6565

6666
Wikibase DataModel has been written by [Jeroen De Dauw](https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw)
67-
as [Wikimedia Germany](https://wikimedia.de) employee for the [Wikidata project](https://wikidata.org/).
67+
and Thiemo Mättig as [Wikimedia Germany](https://wikimedia.de) employees for the [Wikidata project]
68+
(https://wikidata.org/).
6869

6970
Contributions where also made by [several other people]
7071
(https://www.ohloh.net/p/wikibasedatamodel/contributors?sort=commits).

RELEASE-NOTES.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
## Version 2.6.0 (dev)
1111

1212
* Empty strings are now detected as invalid in the `SiteLink` constructor
13-
* Fixed `EntityIdValue::unserialize` accidentally returning itself
13+
* The `SnakList` constructor now throws an `InvalidArgumentException` when getting a non-iterable input
14+
* The `AliasGroup::equals` and `Term::equals` methods no longer incorrectly return true for fallback objects
1415

1516
## Version 2.5.0 (2014-01-20)
1617

WikibaseDataModel.mw.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'version' => WIKIBASE_DATAMODEL_VERSION,
1919
'author' => array(
2020
'[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]',
21+
'Thiemo Mättig',
2122
),
2223
'url' => 'https://github.com/wmde/WikibaseDataModel',
2324
'description' => 'The canonical PHP implementation of the Data Model at the heart of the Wikibase software.',

composer.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
{
1414
"name": "Jeroen De Dauw",
1515
"email": "jeroendedauw@gmail.com",
16-
"homepage": "http://jeroendedauw.com",
17-
"role": "Developer"
16+
"homepage": "http://jeroendedauw.com"
17+
},
18+
{
19+
"name": "Thiemo Mättig"
1820
}
1921
],
2022
"support": {
@@ -42,16 +44,16 @@
4244
}
4345
},
4446
"scripts": {
47+
"ci": [
48+
"composer test",
49+
"composer cs"
50+
],
4551
"test": [
4652
"composer validate --no-interaction",
4753
"phpunit"
4854
],
4955
"cs": [
50-
"vendor/bin/phpcs src/* tests/* --standard=phpcs.xml --extensions=php -sp"
51-
],
52-
"ci": [
53-
"composer test",
54-
"composer cs"
56+
"phpcs src/* tests/* --standard=phpcs.xml --extensions=php -sp"
5557
]
5658
}
5759
}

src/HashArray.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ abstract public function getObjectType();
7070
* @param array|Traversable|null $input
7171
* @param int $flags
7272
* @param string $iterator_class
73+
*
74+
* @throws InvalidArgumentException
7375
*/
7476
public function __construct( $input = null, $flags = 0, $iterator_class = 'ArrayIterator' ) {
7577
parent::__construct( array(), $flags, $iterator_class );
7678

7779
if ( $input !== null ) {
80+
if ( !is_array( $input ) && !( $input instanceof Traversable ) ) {
81+
throw new InvalidArgumentException( '$input must be an array or Traversable' );
82+
}
83+
7884
foreach ( $input as $offset => $value ) {
7985
$this->offsetSet( $offset, $value );
8086
}

src/Term/AliasGroup.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
class AliasGroup implements Comparable, Countable {
2020

2121
/**
22-
* @var string
22+
* @var string Language code identifying the language of the aliases, but note that there is
23+
* nothing this class can do to enforce this convention.
2324
*/
2425
private $languageCode;
2526

@@ -29,7 +30,7 @@ class AliasGroup implements Comparable, Countable {
2930
private $aliases;
3031

3132
/**
32-
* @param string $languageCode
33+
* @param string $languageCode Language of the aliases.
3334
* @param string[] $aliases
3435
*
3536
* @throws InvalidArgumentException

src/Term/Term.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
class Term implements Comparable {
1717

1818
/**
19-
* @var string
19+
* @var string Language code identifying the language of the text, but note that there is
20+
* nothing this class can do to enforce this convention.
2021
*/
2122
private $languageCode;
2223

@@ -26,7 +27,7 @@ class Term implements Comparable {
2627
private $text;
2728

2829
/**
29-
* @param string $languageCode
30+
* @param string $languageCode Language of the text.
3031
* @param string $text
3132
*
3233
* @throws InvalidArgumentException

tests/unit/Entity/Diff/EntityPatcherTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Wikibase\DataModel\Entity\Diff\EntityPatcher;
77
use Wikibase\DataModel\Entity\Diff\ItemDiff;
88
use Wikibase\DataModel\Entity\Item;
9+
use Wikibase\DataModel\Entity\ItemId;
910
use Wikibase\DataModel\Fixtures\EntityOfUnknownType;
1011

1112
/**
@@ -32,8 +33,7 @@ public function testGivenEmptyDiffItemRemainsUnchanged( Item $item ) {
3233
public function itemProvider() {
3334
$argLists = array();
3435

35-
$nonEmptyItem = new Item();
36-
$nonEmptyItem->setId( 2 );
36+
$nonEmptyItem = new Item( new ItemId( 'Q2' ) );
3737

3838
$argLists[] = array( new Item() );
3939
$argLists[] = array( $nonEmptyItem );

tests/unit/Entity/EntityIdParserTest.php renamed to tests/unit/Entity/DispatchingEntityIdParserTest.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,34 @@
99
use Wikibase\DataModel\Entity\PropertyId;
1010

1111
/**
12+
* @covers Wikibase\DataModel\Entity\DispatchingEntityIdParser
1213
* @covers Wikibase\DataModel\Entity\EntityIdParser
1314
*
15+
* @uses Wikibase\DataModel\Entity\BasicEntityIdParser
16+
*
1417
* @group Wikibase
1518
* @group WikibaseDataModel
1619
*
1720
* @licence GNU GPL v2+
1821
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
1922
*/
20-
class EntityIdParserTest extends \PHPUnit_Framework_TestCase {
23+
class DispatchingEntityIdParserTest extends \PHPUnit_Framework_TestCase {
24+
25+
private function getBasicParser() {
26+
return new DispatchingEntityIdParser( BasicEntityIdParser::getBuilders() );
27+
}
2128

2229
/**
23-
* @dataProvider idProvider
30+
* @dataProvider entityIdProvider
2431
*/
2532
public function testCanParseEntityId( EntityId $expected ) {
26-
$actual = $this->newParser()->parse( $expected->getSerialization() );
33+
$parser = $this->getBasicParser();
34+
$actual = $parser->parse( $expected->getSerialization() );
2735

2836
$this->assertEquals( $actual, $expected );
2937
}
3038

31-
public function idProvider() {
39+
public function entityIdProvider() {
3240
return array(
3341
array( new ItemId( 'q42' ) ),
3442
array( new ItemId( 'Q1337' ) ),
@@ -37,16 +45,13 @@ public function idProvider() {
3745
);
3846
}
3947

40-
protected function newParser() {
41-
return new DispatchingEntityIdParser( BasicEntityIdParser::getBuilders() );
42-
}
43-
4448
/**
4549
* @dataProvider invalidIdSerializationProvider
50+
* @expectedException \Wikibase\DataModel\Entity\EntityIdParsingException
4651
*/
47-
public function testCannotParserInvalidId( $invalidIdSerialization ) {
48-
$this->setExpectedException( 'Wikibase\DataModel\Entity\EntityIdParsingException' );
49-
$this->newParser()->parse( $invalidIdSerialization );
52+
public function testCannotParseInvalidId( $invalidIdSerialization ) {
53+
$parser = $this->getBasicParser();
54+
$parser->parse( $invalidIdSerialization );
5055
}
5156

5257
public function invalidIdSerializationProvider() {

tests/unit/Entity/ItemTest.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,7 @@ public function testEmptyItemIsEmpty() {
546546
}
547547

548548
public function testItemWithIdIsEmpty() {
549-
$item = new Item();
550-
$item->setId( 1337 );
549+
$item = new Item( new ItemId( 'Q1337' ) );
551550
$this->assertTrue( $item->isEmpty() );
552551
}
553552

@@ -583,9 +582,7 @@ private function newStatement() {
583582
}
584583

585584
public function testClearRemovesAllButId() {
586-
$item = new Item();
587-
588-
$item->setId( 42 );
585+
$item = new Item( new ItemId( 'Q42' ) );
589586
$item->getFingerprint()->setLabel( 'en', 'foo' );
590587
$item->getSiteLinkList()->addNewSiteLink( 'enwiki', 'Foo' );
591588
$item->addClaim( $this->newStatement() );
@@ -666,9 +663,7 @@ public function testEquals( Item $firstItem, Item $secondItem ) {
666663
}
667664

668665
private function getBaseItem() {
669-
$item = new Item();
670-
671-
$item->setId( 42 );
666+
$item = new Item( new ItemId( 'Q42' ) );
672667
$item->getFingerprint()->setLabel( 'en', 'Same' );
673668
$item->getFingerprint()->setDescription( 'en', 'Same' );
674669
$item->getFingerprint()->setAliasGroup( 'en', array( 'Same' ) );

0 commit comments

Comments
 (0)