diff options
Diffstat (limited to 'SemanticMediaWiki/tests/phpunit/Integration/SemanticDataSerializationDBIntegrationTest.php')
-rw-r--r-- | SemanticMediaWiki/tests/phpunit/Integration/SemanticDataSerializationDBIntegrationTest.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/SemanticMediaWiki/tests/phpunit/Integration/SemanticDataSerializationDBIntegrationTest.php b/SemanticMediaWiki/tests/phpunit/Integration/SemanticDataSerializationDBIntegrationTest.php new file mode 100644 index 00000000..e2faf6b7 --- /dev/null +++ b/SemanticMediaWiki/tests/phpunit/Integration/SemanticDataSerializationDBIntegrationTest.php @@ -0,0 +1,68 @@ +<?php + +namespace SMW\Tests\Integration; + +use SMW\Tests\MwDBaseUnitTestCase; +use SMW\Tests\Util\SemanticDataValidator; + +use SMW\DIWikiPage; +use SMW\DIProperty; +use SMW\SemanticData; +use SMW\DataValueFactory; +use SMW\Subobject; +use SMW\SerializerFactory; + +use SMWDIBlob as DIBlob; + +use Title; + +/** + * @group SMW + * @group SMWExtension + * @group semantic-mediawiki-integration + * @group mediawiki-database + * @group medium + * + * @license GNU GPL v2+ + * @since 2.0 + * + * @author mwjames + */ +class SemanticDataSerializationDBIntegrationTest extends MwDBaseUnitTestCase { + + public function testRoundtripOfSerializedSemanticDataAfterStoreUpdate() { + + $subject = DIWikiPage::newFromTitle( Title::newFromText( __METHOD__ ) ); + $semanticDataBeforeUpdate = new SemanticData( $subject ); + + $subobject = new Subobject( $subject->getTitle() ); + $subobject->setEmptySemanticDataForId( 'SomeSubobjectToSerialize' ); + + $subobject->getSemanticData()->addDataValue( + DataValueFactory::getInstance()->newPropertyValue( 'Foo', 'Bar' ) + ); + + $semanticDataBeforeUpdate->addPropertyObjectValue( + $subobject->getProperty(), + $subobject->getContainer() + ); + + $this->getStore()->updateData( $semanticDataBeforeUpdate ); + + $semanticDataAfterUpdate = $this->getStore()->getSemanticData( $subject ); + + $this->assertNotEquals( + $semanticDataBeforeUpdate->getHash(), + $semanticDataAfterUpdate->getHash(), + 'Assert that the hash is not comparable due to the added _SKEY property during the update' + ); + + $serializerFactory = new SerializerFactory(); + + $this->assertEquals( + $semanticDataAfterUpdate->getHash(), + $serializerFactory->deserialize( $serializerFactory->serialize( $semanticDataAfterUpdate ) )->getHash() + ); + } + +} |