public function testGetHash() { $title = Title::newFromText(__METHOD__); $instance = new SemanticData(DIWikiPage::newFromTitle($title)); $instance->addDataValue(DataValueFactory::getInstance()->newPropertyValue('Has fooQuex', 'Bar')); $subobject = $this->newSubobject($title); $instance->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer()); $this->assertInternalType('string', $instance->getHash()); }
public function testThatChangingDataDoesEnforceDifferentHash() { $instance = new SemanticData(new DIWikiPage('Foo', NS_MAIN)); $firstHash = $instance->getHash(); $instance->addDataValue($this->dataValueFactory->newDataValueByText('Foo', 'Bar')); $secondHash = $instance->getHash(); $this->assertNotEquals($firstHash, $secondHash); $subobject = new Subobject(Title::newFromText('Foo')); $subobject->setEmptyContainerForId('Foo'); $subobject->addDataValue($this->dataValueFactory->newDataValueByText('Foo', 'Bar')); $instance->addSubSemanticData($subobject->getSemanticData()); $thirdHash = $instance->getHash(); $this->assertNotEquals($secondHash, $thirdHash); // Remove the data added in the third step and expect // the hash from the second $instance->removeSubSemanticData($subobject->getSemanticData()); $this->assertEquals($secondHash, $instance->getHash()); }