Skip to content

Commit b83b175

Browse files
yerduaWMDE bot
authored andcommitted
Make dataProviders static in lib, client, view, rest-api
non-static dataProvider functions are deprecated as of PHPUnit 10. Most of `repo` was covered in prior commits. With the exception of a few remaining files that are entangled with other repos, this covers: - repo/rest-api - lib - client - view Bug: T337154 Change-Id: I3be5623ebacc976c941cdee25992233b3846e3a4
1 parent 4064f97 commit b83b175

6 files changed

Lines changed: 166 additions & 166 deletions

File tree

tests/unit/ByPropertyIdArrayTest.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class ByPropertyIdArrayTest extends \PHPUnit\Framework\TestCase {
3434
public function testGivenNull_constructorAssumesEmptyArray() {
3535
$indexedArray = new ByPropertyIdArray( null );
3636

37-
$this->assertSame( 0, $indexedArray->count() );
37+
self::assertSame( 0, $indexedArray->count() );
3838
}
3939

4040
public function testGivenNonTraversableObject_constructorDoesNotCastObjectToArray() {
@@ -59,7 +59,7 @@ public function testArrayObjectNotConstructedFromObject() {
5959
// constructed from an object." This test makes sure it was not constructed from an object.
6060
$byPropertyIdArray->append( $statement2 );
6161

62-
$this->assertCount( 2, $byPropertyIdArray );
62+
self::assertCount( 2, $byPropertyIdArray );
6363
}
6464

6565
/**
@@ -142,7 +142,7 @@ public function testGetIds( array $objects ) {
142142

143143
$indexedArray->buildIndex();
144144

145-
$this->assertEquals(
145+
self::assertEquals(
146146
array_values( $expected ),
147147
array_values( $indexedArray->getPropertyIds() )
148148
);
@@ -170,11 +170,11 @@ public function testGetById( array $objects ) {
170170
foreach ( $ids as $id ) {
171171
foreach ( $indexedArray->getByPropertyId( $id ) as $obtainedObject ) {
172172
$allObtainedObjects[] = $obtainedObject;
173-
$this->assertEquals( $id, $obtainedObject->getPropertyId() );
173+
self::assertEquals( $id, $obtainedObject->getPropertyId() );
174174
}
175175
}
176176

177-
$this->assertEquals(
177+
self::assertEquals(
178178
array_values( $objects ),
179179
array_values( $allObtainedObjects )
180180
);
@@ -194,15 +194,15 @@ public function testRemoveObject( array $objects ) {
194194
$removeObject->invokeArgs( $indexedArray, [ $objects[0] ] );
195195
$removeObject->invokeArgs( $indexedArray, [ $objects[$lastIndex] ] );
196196

197-
$this->assertNotContains(
197+
self::assertNotContains(
198198
$objects[0], $indexedArray->getByPropertyId( $objects[0]->getPropertyId() )
199199
);
200200

201-
$this->assertNotContains( $objects[$lastIndex],
201+
self::assertNotContains( $objects[$lastIndex],
202202
$indexedArray->getByPropertyId( $objects[1]->getPropertyId() ) );
203203

204-
$this->assertNotContains( $objects[0], $indexedArray->toFlatArray() );
205-
$this->assertNotContains( $objects[$lastIndex], $indexedArray->toFlatArray() );
204+
self::assertNotContains( $objects[0], $indexedArray->toFlatArray() );
205+
self::assertNotContains( $objects[$lastIndex], $indexedArray->toFlatArray() );
206206
}
207207

208208
public function testGetByNotSetIdThrowsException() {
@@ -244,7 +244,7 @@ public function testGetFlatArrayIndexOfObject( array $objects ) {
244244
$indicesDestination[$indexedArray->getFlatArrayIndexOfObject( $object )] = $object;
245245
}
246246

247-
$this->assertEquals( $indicesSource, $indicesDestination );
247+
self::assertEquals( $indicesSource, $indicesDestination );
248248
}
249249

250250
/**
@@ -254,11 +254,11 @@ public function testToFlatArray( array $objects ) {
254254
$indexedArray = new ByPropertyIdArray( $objects );
255255
$indexedArray->buildIndex();
256256

257-
$this->assertEquals( $objects, $indexedArray->toFlatArray() );
257+
self::assertEquals( $objects, $indexedArray->toFlatArray() );
258258
}
259259

260-
public function moveProvider() {
261-
$c = $this->statementsProvider();
260+
public static function moveProvider() {
261+
$c = self::statementsProvider();
262262
$argLists = [];
263263

264264
$argLists[] = [ $c, $c[0], 0, $c ];
@@ -333,11 +333,11 @@ public function testMoveObjectToIndex(
333333
$reindexedArray[] = $o;
334334
}
335335

336-
$this->assertEquals( $objectsDestination, $reindexedArray );
336+
self::assertEquals( $objectsDestination, $reindexedArray );
337337
}
338338

339339
public function testMoveThrowingOutOfBoundsExceptionIfObjectNotPresent() {
340-
$statements = $this->statementsProvider();
340+
$statements = self::statementsProvider();
341341
$indexedArray = new ByPropertyIdArray( $statements );
342342
$indexedArray->buildIndex();
343343

@@ -350,7 +350,7 @@ public function testMoveThrowingOutOfBoundsExceptionIfObjectNotPresent() {
350350
}
351351

352352
public function testMoveThrowingOutOfBoundsExceptionOnInvalidIndex() {
353-
$statements = $this->statementsProvider();
353+
$statements = self::statementsProvider();
354354
$indexedArray = new ByPropertyIdArray( $statements );
355355
$indexedArray->buildIndex();
356356

@@ -359,8 +359,8 @@ public function testMoveThrowingOutOfBoundsExceptionOnInvalidIndex() {
359359
$indexedArray->moveObjectToIndex( $statements[0], 9999 );
360360
}
361361

362-
public function addProvider() {
363-
$c = $this->statementsProvider();
362+
public static function addProvider() {
363+
$c = self::statementsProvider();
364364

365365
$argLists = [];
366366

@@ -404,7 +404,7 @@ public function testAddObjectAtIndex(
404404

405405
$indexedArray->addObjectAtIndex( $object, $index );
406406

407-
$this->assertEquals( $objectsDestination, $indexedArray->toFlatArray() );
407+
self::assertEquals( $objectsDestination, $indexedArray->toFlatArray() );
408408
}
409409

410410
}

tests/unit/Entity/ItemTest.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
*/
3131
class ItemTest extends \PHPUnit\Framework\TestCase {
3232

33-
private function getNewEmpty() {
33+
private static function getNewEmpty() {
3434
return new Item();
3535
}
3636

@@ -188,7 +188,7 @@ public function testItemWithStuffIsNotEmpty() {
188188
$this->assertFalse( $item->isEmpty() );
189189

190190
$item = new Item();
191-
$item->getStatements()->addStatement( $this->newStatement() );
191+
$item->getStatements()->addStatement( self::newStatement() );
192192
$this->assertFalse( $item->isEmpty() );
193193
}
194194

@@ -198,7 +198,7 @@ public function testItemWithSitelinksHasSitelinks() {
198198
$this->assertFalse( $item->getSiteLinkList()->isEmpty() );
199199
}
200200

201-
private function newStatement() {
201+
private static function newStatement() {
202202
$statement = new Statement( new PropertyNoValueSnak( 42 ) );
203203
$statement->setGuid( 'kittens' );
204204
return $statement;
@@ -270,7 +270,7 @@ public function testEquals( Item $firstItem, Item $secondItem ) {
270270
/**
271271
* @return Item
272272
*/
273-
private function getBaseItem() {
273+
private static function getBaseItem() {
274274
$item = new Item( new ItemId( 'Q42' ) );
275275
$item->setLabel( 'en', 'Same' );
276276
$item->setDescription( 'en', 'Same' );
@@ -281,25 +281,25 @@ private function getBaseItem() {
281281
return $item;
282282
}
283283

284-
public function notEqualsProvider() {
285-
$differentLabel = $this->getBaseItem();
284+
public static function notEqualsProvider() {
285+
$differentLabel = self::getBaseItem();
286286
$differentLabel->setLabel( 'en', 'Different' );
287287

288-
$differentDescription = $this->getBaseItem();
288+
$differentDescription = self::getBaseItem();
289289
$differentDescription->setDescription( 'en', 'Different' );
290290

291-
$differentAlias = $this->getBaseItem();
291+
$differentAlias = self::getBaseItem();
292292
$differentAlias->setAliases( 'en', [ 'Different' ] );
293293

294-
$differentSiteLink = $this->getBaseItem();
294+
$differentSiteLink = self::getBaseItem();
295295
$differentSiteLink->getSiteLinkList()->removeLinkWithSiteId( 'enwiki' );
296296
$differentSiteLink->getSiteLinkList()->addNewSiteLink( 'enwiki', 'Different' );
297297

298-
$differentStatement = $this->getBaseItem();
298+
$differentStatement = self::getBaseItem();
299299
$differentStatement->setStatements( new StatementList() );
300300
$differentStatement->getStatements()->addNewStatement( new PropertyNoValueSnak( 24 ) );
301301

302-
$item = $this->getBaseItem();
302+
$item = self::getBaseItem();
303303

304304
return [
305305
'empty' => [ $item, new Item() ],
@@ -401,7 +401,7 @@ public static function labelProvider() {
401401
* @param string $moarText
402402
*/
403403
public function testSetLabel( $languageCode, $labelText, $moarText = 'ohi there' ) {
404-
$entity = $this->getNewEmpty();
404+
$entity = self::getNewEmpty();
405405

406406
$entity->setLabel( $languageCode, $labelText );
407407

@@ -419,7 +419,7 @@ public function testSetLabel( $languageCode, $labelText, $moarText = 'ohi there'
419419
* @param string $moarText
420420
*/
421421
public function testSetDescription( $languageCode, $description, $moarText = 'ohi there' ) {
422-
$entity = $this->getNewEmpty();
422+
$entity = self::getNewEmpty();
423423

424424
$entity->setDescription( $languageCode, $description );
425425

@@ -459,7 +459,7 @@ public static function aliasesProvider() {
459459
* @dataProvider aliasesProvider
460460
*/
461461
public function testSetAliases( array $aliasesLists ) {
462-
$entity = $this->getNewEmpty();
462+
$entity = self::getNewEmpty();
463463

464464
foreach ( $aliasesLists as $langCode => $aliasesList ) {
465465
foreach ( $aliasesList as $aliases ) {
@@ -487,11 +487,11 @@ public function testSetEmptyAlias() {
487487
$this->assertFalse( $item->getAliasGroups()->hasGroupForLanguage( 'en' ) );
488488
}
489489

490-
public function instanceProvider() {
490+
public static function instanceProvider() {
491491
$entities = [];
492492

493493
// empty
494-
$entity = $this->getNewEmpty();
494+
$entity = self::getNewEmpty();
495495
$entities[] = $entity;
496496

497497
// ID only
@@ -501,7 +501,7 @@ public function instanceProvider() {
501501
$entities[] = $entity;
502502

503503
// with labels and stuff
504-
$entity = $this->getNewEmpty();
504+
$entity = self::getNewEmpty();
505505
$entity->setAliases( 'en', [ 'o', 'noez' ] );
506506
$entity->setLabel( 'de', 'spam' );
507507
$entity->setDescription( 'en', 'foo bar baz' );
@@ -565,7 +565,7 @@ public function testSerialize( Item $entity ) {
565565
}
566566

567567
public function testWhenNoStuffIsSet_getFingerprintReturnsEmptyFingerprint() {
568-
$entity = $this->getNewEmpty();
568+
$entity = self::getNewEmpty();
569569

570570
$this->assertEquals(
571571
new Fingerprint(),
@@ -574,7 +574,7 @@ public function testWhenNoStuffIsSet_getFingerprintReturnsEmptyFingerprint() {
574574
}
575575

576576
public function testWhenLabelsAreSet_getFingerprintReturnsFingerprintWithLabels() {
577-
$entity = $this->getNewEmpty();
577+
$entity = self::getNewEmpty();
578578

579579
$entity->setLabel( 'en', 'foo' );
580580
$entity->setLabel( 'de', 'bar' );
@@ -591,7 +591,7 @@ public function testWhenLabelsAreSet_getFingerprintReturnsFingerprintWithLabels(
591591
}
592592

593593
public function testWhenTermsAreSet_getFingerprintReturnsFingerprintWithTerms() {
594-
$entity = $this->getNewEmpty();
594+
$entity = self::getNewEmpty();
595595

596596
$entity->setLabel( 'en', 'foo' );
597597
$entity->setDescription( 'en', 'foo bar' );
@@ -614,14 +614,14 @@ public function testWhenTermsAreSet_getFingerprintReturnsFingerprintWithTerms()
614614
}
615615

616616
public function testGivenEmptyFingerprint_noTermsAreSet() {
617-
$entity = $this->getNewEmpty();
617+
$entity = self::getNewEmpty();
618618
$entity->setFingerprint( new Fingerprint() );
619619

620620
$this->assertTrue( $entity->getFingerprint()->isEmpty() );
621621
}
622622

623623
public function testGivenEmptyFingerprint_existingTermsAreRemoved() {
624-
$entity = $this->getNewEmpty();
624+
$entity = self::getNewEmpty();
625625

626626
$entity->setLabel( 'en', 'foo' );
627627
$entity->setDescription( 'en', 'foo bar' );
@@ -645,7 +645,7 @@ public function testWhenSettingFingerprint_getFingerprintReturnsIt() {
645645
] )
646646
);
647647

648-
$entity = $this->getNewEmpty();
648+
$entity = self::getNewEmpty();
649649
$entity->setFingerprint( $fingerprint );
650650
$newFingerprint = $entity->getFingerprint();
651651

@@ -727,7 +727,7 @@ public function testClear( Item $item ) {
727727
$this->assertTrue( $item->isEmpty(), 'cleared Item should be empty' );
728728
}
729729

730-
public function clearableProvider() {
730+
public static function clearableProvider() {
731731
return [
732732
'empty' => [ new Item( new ItemId( 'Q23' ) ) ],
733733
'with fingerprint' => [
@@ -748,7 +748,7 @@ public function clearableProvider() {
748748
new ItemId( 'Q321' ),
749749
null,
750750
null,
751-
new StatementList( $this->newStatement() )
751+
new StatementList( self::newStatement() )
752752
),
753753
],
754754
];

0 commit comments

Comments
 (0)