Skip to content

Commit b00ada5

Browse files
committed
Add Item::setStatements
1 parent 181e35d commit b00ada5

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/Entity/Item.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,15 @@ public function getStatements() {
342342
return $this->statements;
343343
}
344344

345+
/**
346+
* @since 1.0
347+
*
348+
* @param StatementList $statements
349+
*/
350+
public function setStatements( StatementList $statements ) {
351+
$this->statements = $statements;
352+
}
353+
345354
/**
346355
* @deprecated since 1.0, use getStatements instead
347356
*
@@ -352,7 +361,7 @@ public function getClaims() {
352361
}
353362

354363
/**
355-
* @deprecated since 1.0, use getStatements instead
364+
* @deprecated since 1.0, use setStatements instead
356365
*
357366
* @param Claims $claims
358367
*/

tests/unit/Entity/ItemTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ public function testNewClaimReturnsStatementWithProvidedMainSnak() {
695695
$this->assertEquals( $snak, $statement->getMainSnak() );
696696
}
697697

698-
public function testSetStatements() {
698+
public function testSetClaims() {
699699
$item = Item::newEmpty();
700700

701701
$statement0 = new Statement( new PropertyNoValueSnak( 42 ) );
@@ -805,4 +805,12 @@ public function testCanConstructWithStatementList() {
805805
);
806806
}
807807

808+
public function testSetStatements() {
809+
$item = Item::newEmpty();
810+
$item->getStatements()->addNewStatement( new PropertyNoValueSnak( 42 ) );
811+
812+
$item->setStatements( new StatementList() );
813+
$this->assertEquals( new StatementList(), $item->getStatements() );
814+
}
815+
808816
}

0 commit comments

Comments
 (0)