Skip to content

Commit 0c86f5c

Browse files
committed
Fix major bug in Property::clear
1 parent 3d38945 commit 0c86f5c

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
@@ -237,6 +237,7 @@ public function isEmpty() {
237237
*/
238238
public function clear() {
239239
$this->fingerprint = new Fingerprint();
240+
$this->statements = new StatementList();
240241
}
241242

242243
/**

tests/unit/Entity/PropertyTest.php

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

119119
public function testClearRemovesAllButId() {
120120
$property = Property::newFromType( 'string' );
121-
122121
$property->setId( 42 );
123122
$property->getFingerprint()->setLabel( 'en', 'foo' );
123+
$property->getStatements()->addNewStatement( new PropertyNoValueSnak( 1 ) );
124124

125125
$property->clear();
126126

127127
$this->assertEquals( new PropertyId( 'P42' ), $property->getId() );
128-
$this->assertTrue( $property->getFingerprint()->isEmpty() );
128+
$this->assertTrue( $property->isEmpty() );
129129
}
130130

131131
public function testGetStatementsReturnsEmptyListForEmptyProperty() {

0 commit comments

Comments
 (0)