Skip to content

Commit 136cb9f

Browse files
committed
Merge pull request #360 from wmde/setid
Reduce number of setId calls
2 parents 58cca5b + bd8868f commit 136cb9f

2 files changed

Lines changed: 5 additions & 10 deletions

File tree

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/ItemTest.php

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

611611
public function testItemWithIdIsEmpty() {
612-
$item = new Item();
613-
$item->setId( 1337 );
612+
$item = new Item( new ItemId( 'Q1337' ) );
614613
$this->assertTrue( $item->isEmpty() );
615614
}
616615

@@ -646,9 +645,7 @@ private function newStatement() {
646645
}
647646

648647
public function testClearRemovesAllButId() {
649-
$item = new Item();
650-
651-
$item->setId( 42 );
648+
$item = new Item( new ItemId( 'Q42' ) );
652649
$item->getFingerprint()->setLabel( 'en', 'foo' );
653650
$item->getSiteLinkList()->addNewSiteLink( 'enwiki', 'Foo' );
654651
$item->addClaim( $this->newStatement() );
@@ -729,9 +726,7 @@ public function testEquals( Item $firstItem, Item $secondItem ) {
729726
}
730727

731728
private function getBaseItem() {
732-
$item = new Item();
733-
734-
$item->setId( 42 );
729+
$item = new Item( new ItemId( 'Q42' ) );
735730
$item->getFingerprint()->setLabel( 'en', 'Same' );
736731
$item->getFingerprint()->setDescription( 'en', 'Same' );
737732
$item->getFingerprint()->setAliasGroup( 'en', array( 'Same' ) );

0 commit comments

Comments
 (0)