Skip to content

Commit 9be0193

Browse files
committed
Merge pull request #403 from wmde/dataProviderDocs
Clean-up dataProvider docs and type hints
2 parents cbd3f47 + 4cc366a commit 9be0193

11 files changed

Lines changed: 29 additions & 62 deletions

tests/unit/ByPropertyIdArrayTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ function( Snak $snak ) {
117117

118118
/**
119119
* @dataProvider listProvider
120-
* @param Snak[] $objects
121120
*/
122121
public function testGetIds( array $objects ) {
123122
$indexedArray = new ByPropertyIdArray( $objects );
@@ -140,7 +139,6 @@ public function testGetIds( array $objects ) {
140139

141140
/**
142141
* @dataProvider listProvider
143-
* @param array $objects
144142
*/
145143
public function testGetById( array $objects ) {
146144
$indexedArray = new ByPropertyIdArray( $objects );
@@ -172,7 +170,6 @@ public function testGetById( array $objects ) {
172170

173171
/**
174172
* @dataProvider listProvider
175-
* @param array $objects
176173
*/
177174
public function testRemoveObject( array $objects ) {
178175
$lastIndex = count( $objects ) - 1;
@@ -222,7 +219,6 @@ public function testNotBuildExceptionIsThrownForGetPropertyIds() {
222219

223220
/**
224221
* @dataProvider listProvider
225-
* @param array $objects
226222
*/
227223
public function testGetFlatArrayIndexOfObject( array $objects ) {
228224
$indexedArray = new ByPropertyIdArray( $objects );
@@ -242,7 +238,6 @@ public function testGetFlatArrayIndexOfObject( array $objects ) {
242238

243239
/**
244240
* @dataProvider listProvider
245-
* @param array $objects
246241
*/
247242
public function testToFlatArray( array $objects ) {
248243
$indexedArray = new ByPropertyIdArray( $objects );
@@ -308,10 +303,10 @@ public function moveProvider() {
308303

309304
/**
310305
* @dataProvider moveProvider
311-
* @param array $objectsSource
306+
* @param object[] $objectsSource
312307
* @param object $object
313308
* @param int $toIndex
314-
* @param array $objectsDestination
309+
* @param object[] $objectsDestination
315310
*/
316311
public function testMoveObjectToIndex(
317312
array $objectsSource,
@@ -387,10 +382,10 @@ public function addProvider() {
387382

388383
/**
389384
* @dataProvider addProvider
390-
* @param array $objectsSource
385+
* @param object[] $objectsSource
391386
* @param object $object
392-
* @param int $index
393-
* @param array $objectsDestination
387+
* @param int|null $index
388+
* @param object[] $objectsDestination
394389
*/
395390
public function testAddObjectAtIndex(
396391
array $objectsSource,

tests/unit/ByPropertyIdGrouperTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public function provideGetPropertyIds() {
5050

5151
/**
5252
* @dataProvider provideGetPropertyIds
53-
*
5453
* @param PropertyIdProvider[] $propertyIdProviders
5554
* @param PropertyId[] $expectedPropertyIds
5655
*/
@@ -82,7 +81,6 @@ public function provideGetByPropertyId() {
8281

8382
/**
8483
* @dataProvider provideGetByPropertyId
85-
*
8684
* @param PropertyIdProvider[] $propertyIdProviders
8785
* @param string $propertyId
8886
* @param string[] $expectedValues
@@ -120,10 +118,9 @@ public function provideHasPropertyId() {
120118

121119
/**
122120
* @dataProvider provideHasPropertyId
123-
*
124121
* @param PropertyIdProvider[] $propertyIdProviders
125122
* @param string $propertyId
126-
* @param boolean $expectedValue
123+
* @param bool $expectedValue
127124
*/
128125
public function testHasPropertyId( array $propertyIdProviders, $propertyId, $expectedValue ) {
129126
$byPropertyIdGrouper = new ByPropertyIdGrouper( $propertyIdProviders );

tests/unit/Claim/ClaimGuidTest.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Exception;
66
use Wikibase\DataModel\Claim\ClaimGuid;
7+
use Wikibase\DataModel\Entity\EntityId;
78
use Wikibase\DataModel\Entity\ItemId;
89

910
/**
@@ -20,12 +21,11 @@ class ClaimGuidTest extends \PHPUnit_Framework_TestCase {
2021

2122
/**
2223
* @dataProvider provideConstructionData
23-
*
24-
* @param $entityId
25-
* @param $guid
26-
* @param $expected
24+
* @param EntityId $entityId
25+
* @param string $guid
26+
* @param string $expected
2727
*/
28-
public function testConstructor( $entityId, $guid, $expected ) {
28+
public function testConstructor( EntityId $entityId, $guid, $expected ) {
2929
$claimGuid = new ClaimGuid( $entityId, $guid );
3030

3131
$this->assertEquals( $expected, $claimGuid->getSerialization() );
@@ -56,9 +56,6 @@ public function provideConstructionData() {
5656

5757
/**
5858
* @dataProvider provideBadConstruction
59-
*
60-
* @param $entityId
61-
* @param $guid
6259
*/
6360
public function testBadConstruction( $entityId, $guid ) {
6461
$this->setExpectedException( 'InvalidArgumentException' );
@@ -90,21 +87,19 @@ public function provideClaimGuids() {
9087

9188
/**
9289
* @dataProvider provideClaimGuids
93-
*
9490
* @param ClaimGuid $claimGuid
9591
*/
96-
public function testEquals( $claimGuid ) {
92+
public function testEquals( ClaimGuid $claimGuid ) {
9793
$claimGuidCopy = clone $claimGuid;
9894
$this->assertTrue( $claimGuid->equals( $claimGuidCopy ) );
9995
$this->assertTrue( $claimGuidCopy->equals( $claimGuid ) );
10096
}
10197

10298
/**
10399
* @dataProvider provideClaimGuids
104-
*
105100
* @param ClaimGuid $claimGuid
106101
*/
107-
public function testNotEquals( $claimGuid ) {
102+
public function testNotEquals( ClaimGuid $claimGuid ) {
108103
$notEqualClaimGuid = new ClaimGuid( new ItemId( 'q9999' ), 'someguid' );
109104
$this->assertFalse( $claimGuid->equals( $notEqualClaimGuid ) );
110105
$this->assertFalse( $notEqualClaimGuid->equals( $claimGuid ) );

tests/unit/Claim/ClaimListAccessTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ public function claimTestProvider() {
6262

6363
/**
6464
* @dataProvider claimTestProvider
65-
*
6665
* @param ClaimListAccess $list
67-
* @param array $claims
66+
* @param Claim[] $claims
6867
*/
6968
public function testAllOfTheStuff( ClaimListAccess $list, array $claims ) {
7069
foreach ( $claims as $claim ) {

tests/unit/Claim/ClaimTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ function( array $arguments ) {
6060

6161
/**
6262
* @dataProvider constructorProvider
63-
*
6463
* @param Snak $mainSnak
6564
* @param Snaks|null $qualifiers
6665
*/
@@ -183,7 +182,6 @@ public function testGetRank( Claim $claim ) {
183182

184183
/**
185184
* @dataProvider instanceProvider
186-
*
187185
* @param Claim $claim
188186
*/
189187
public function testGetAllSnaks( Claim $claim ) {

tests/unit/Entity/Diff/EntityDiffTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ public function isEmptyProvider() {
5252

5353
/**
5454
* @dataProvider isEmptyProvider
55-
*
56-
* @param array $diffOps
57-
* @param boolean $isEmpty
55+
* @param Diff[] $diffOps
56+
* @param bool $isEmpty
5857
*/
5958
public function testIsEmpty( array $diffOps, $isEmpty ) {
6059
$diff = new EntityDiff( $diffOps );

tests/unit/Entity/Diff/ItemDiffTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,8 @@ public function isEmptyProvider() {
251251

252252
/**
253253
* @dataProvider isEmptyProvider
254-
*
255-
* @param array $diffOps
256-
* @param boolean $isEmpty
254+
* @param Diff[] $diffOps
255+
* @param bool $isEmpty
257256
*/
258257
public function testIsEmpty( array $diffOps, $isEmpty ) {
259258
$diff = new ItemDiff( $diffOps );

tests/unit/Entity/EntityTest.php

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,15 @@ public function descriptionProvider() {
107107
/**
108108
* @dataProvider descriptionProvider
109109
* @param string $languageCode
110-
* @param string $labelText
110+
* @param string $description
111111
* @param string $moarText
112112
*/
113-
public function testSetDescription( $languageCode, $labelText, $moarText = 'ohi there' ) {
113+
public function testSetDescription( $languageCode, $description, $moarText = 'ohi there' ) {
114114
$entity = $this->getNewEmpty();
115115

116-
$entity->setDescription( $languageCode, $labelText );
116+
$entity->setDescription( $languageCode, $description );
117117

118-
$this->assertEquals( $labelText, $entity->getDescription( $languageCode ) );
118+
$this->assertEquals( $description, $entity->getDescription( $languageCode ) );
119119

120120
$entity->setDescription( $languageCode, $moarText );
121121

@@ -125,26 +125,26 @@ public function testSetDescription( $languageCode, $labelText, $moarText = 'ohi
125125
/**
126126
* @dataProvider descriptionProvider
127127
* @param string $languageCode
128-
* @param string $labelText
128+
* @param string $description
129129
*/
130-
public function testGetDescription( $languageCode, $labelText ) {
130+
public function testGetDescription( $languageCode, $description ) {
131131
$entity = $this->getNewEmpty();
132132

133133
$this->assertFalse( $entity->getDescription( $languageCode ) );
134134

135-
$entity->setDescription( $languageCode, $labelText );
135+
$entity->setDescription( $languageCode, $description );
136136

137-
$this->assertEquals( $labelText, $entity->getDescription( $languageCode ) );
137+
$this->assertEquals( $description, $entity->getDescription( $languageCode ) );
138138
}
139139

140140
/**
141141
* @dataProvider descriptionProvider
142142
* @param string $languageCode
143-
* @param string $labelText
143+
* @param string $description
144144
*/
145-
public function testRemoveDescription( $languageCode, $labelText ) {
145+
public function testRemoveDescription( $languageCode, $description ) {
146146
$entity = $this->getNewEmpty();
147-
$entity->setDescription( $languageCode, $labelText );
147+
$entity->setDescription( $languageCode, $description );
148148
$entity->removeDescription( $languageCode );
149149
$this->assertFalse( $entity->getDescription( $languageCode ) );
150150
}
@@ -372,7 +372,6 @@ public function instanceProvider() {
372372

373373
/**
374374
* @dataProvider instanceProvider
375-
*
376375
* @param Entity $entity
377376
*/
378377
public function testCopy( Entity $entity ) {
@@ -399,7 +398,6 @@ public function testCopyRetainsLabels() {
399398

400399
/**
401400
* @dataProvider instanceProvider
402-
*
403401
* @param Entity $entity
404402
*/
405403
public function testSerialize( Entity $entity ) {
@@ -415,7 +413,6 @@ public function testSerialize( Entity $entity ) {
415413

416414
/**
417415
* @dataProvider instanceProvider
418-
*
419416
* @param Entity $entity
420417
*/
421418
public function testHasClaims( Entity $entity ) {
@@ -490,7 +487,6 @@ public function diffProvider() {
490487

491488
/**
492489
* @dataProvider diffProvider
493-
*
494490
* @param Entity $entity0
495491
* @param Entity $entity1
496492
* @param EntityDiff $expected
@@ -507,7 +503,6 @@ public function testDiffEntities( Entity $entity0, Entity $entity1, EntityDiff $
507503

508504
/**
509505
* @dataProvider instanceProvider
510-
*
511506
* @param Entity $entity
512507
*/
513508
public function testGetClaims( Entity $entity ) {
@@ -518,7 +513,6 @@ public function testGetClaims( Entity $entity ) {
518513

519514
/**
520515
* @dataProvider instanceProvider
521-
*
522516
* @param Entity $entity
523517
*/
524518
public function testGetAllSnaks( Entity $entity ) {

tests/unit/ReferenceListTest.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public function invalidConstructorArgumentsProvider() {
7979

8080
/**
8181
* @dataProvider instanceProvider
82-
*
8382
* @param ReferenceList $array
8483
*/
8584
public function testHasReferenceBeforeRemoveButNotAfter( ReferenceList $array ) {
@@ -115,7 +114,6 @@ public function testGivenCloneOfReferenceInList_hasReferenceReturnsTrue() {
115114

116115
/**
117116
* @dataProvider instanceProvider
118-
*
119117
* @param ReferenceList $array
120118
*/
121119
public function testRemoveReference( ReferenceList $array ) {
@@ -213,7 +211,6 @@ public function testGivenEmptyReferenceAndIndex_addReferenceDoesNotAdd() {
213211

214212
/**
215213
* @dataProvider instanceProvider
216-
*
217214
* @param ReferenceList $array
218215
*/
219216
public function testIndexOf( ReferenceList $array ) {
@@ -227,7 +224,6 @@ public function testIndexOf( ReferenceList $array ) {
227224

228225
/**
229226
* @dataProvider instanceProvider
230-
*
231227
* @param ReferenceList $array
232228
*/
233229
public function testEquals( ReferenceList $array ) {
@@ -237,7 +233,6 @@ public function testEquals( ReferenceList $array ) {
237233

238234
/**
239235
* @dataProvider instanceProvider
240-
*
241236
* @param ReferenceList $array
242237
*/
243238
public function testGetHashReturnsString( ReferenceList $array ) {
@@ -246,7 +241,6 @@ public function testGetHashReturnsString( ReferenceList $array ) {
246241

247242
/**
248243
* @dataProvider instanceProvider
249-
*
250244
* @param ReferenceList $array
251245
*/
252246
public function testGetHashValueIsTheSameForClone( ReferenceList $array ) {

tests/unit/ReferenceTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ public function instanceProvider() {
8181

8282
/**
8383
* @dataProvider snakListProvider
84-
*
8584
* @param Snaks $snaks
8685
*/
8786
public function testConstructor( Snaks $snaks ) {
@@ -257,7 +256,6 @@ public function testCanConstructWithSnakArray() {
257256

258257
/**
259258
* @dataProvider invalidConstructorArgumentsProvider
260-
* @param mixed $snaks
261259
* @expectedException InvalidArgumentException
262260
*/
263261
public function testGivenInvalidConstructorArguments_constructorThrowsException( $snaks ) {

0 commit comments

Comments
 (0)