Skip to content

Commit 5923189

Browse files
committed
Merge pull request #616 from wmde/propertyClear
Fix major bug in Property::clear
2 parents 59061d5 + 0c86f5c commit 5923189

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/Entity/Property.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public function isEmpty() {
230230
*/
231231
public function clear() {
232232
$this->fingerprint = new Fingerprint();
233+
$this->statements = new StatementList();
233234
}
234235

235236
/**

tests/unit/Entity/PropertyTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ public function testPropertyWithFingerprintIsNotEmpty() {
115115

116116
public function testClearRemovesAllButId() {
117117
$property = Property::newFromType( 'string' );
118-
119118
$property->setId( 42 );
120119
$property->getFingerprint()->setLabel( 'en', 'foo' );
120+
$property->getStatements()->addNewStatement( new PropertyNoValueSnak( 1 ) );
121121

122122
$property->clear();
123123

124124
$this->assertEquals( new PropertyId( 'P42' ), $property->getId() );
125-
$this->assertTrue( $property->getFingerprint()->isEmpty() );
125+
$this->assertTrue( $property->isEmpty() );
126126
}
127127

128128
public function testGetStatementsReturnsEmptyListForEmptyProperty() {

0 commit comments

Comments
 (0)