Skip to content

Commit 6716415

Browse files
tobanaddshore
authored andcommitted
Ensure hash stability
Reviewed and added tests for the missing ones. ReferenceList: exists Statement: new Reference: new SnakList: exists SnakObject - DerivedPropertyValueSnakTest: exists - PropertyNoValueSnakTest: exists - PropertySomeValueSnakTest: exists - PropertyValueSnakTest: exists Bug: T253637
1 parent cd1faf2 commit 6716415

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

tests/unit/ReferenceTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,11 @@ public function testReferenceDoesNotEqualReferenceWithDifferentSnakProperty() {
188188
$this->assertFalse( $reference0->equals( $reference1 ) );
189189
}
190190

191+
public function testReferenceHashStability() {
192+
$reference = new Reference( [ new PropertyNoValueSnak( 42 ) ] );
193+
$this->assertSame( 'f2be45ba65676e69367433547812db03b8c661ef', $reference->getHash() );
194+
}
195+
191196
public function testReferenceDoesNotEqualReferenceWithMoreSnaks() {
192197
$reference0 = new Reference( [ new PropertyNoValueSnak( 42 ) ] );
193198

tests/unit/Statement/StatementTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ public function testGetGuid( Statement $statement ) {
7979
$this->assertEquals( 'foobar', $statement->getGuid() );
8080
}
8181

82+
public function testHashStability() {
83+
$mainSnak = new PropertyNoValueSnak( new PropertyId( 'P42' ) );
84+
$statement = new Statement( $mainSnak );
85+
$this->assertSame( '50c73da6759fd31868fb0cc9c218969fa776f62c', $statement->getHash() );
86+
}
87+
8288
public function testSetAndGetMainSnak() {
8389
$mainSnak = new PropertyNoValueSnak( new PropertyId( 'P42' ) );
8490
$statement = new Statement( $mainSnak );

0 commit comments

Comments
 (0)