summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2014-12-23 17:49:26 +0100
committerAlex Legler <alex@a3li.li>2014-12-23 17:49:26 +0100
commite352fff59842ca14fbfd81ee1c4a64297bb598c5 (patch)
tree153f268484aa5cc41cacf912bdce8c4847df222d /SemanticMediaWiki/tests/phpunit/Integration/SemanticDataSerializationDBIntegrationTest.php
downloadextensions-e352fff59842ca14fbfd81ee1c4a64297bb598c5.tar.gz
extensions-e352fff59842ca14fbfd81ee1c4a64297bb598c5.tar.bz2
extensions-e352fff59842ca14fbfd81ee1c4a64297bb598c5.zip
Add initial set of additional extensions
Diffstat (limited to 'SemanticMediaWiki/tests/phpunit/Integration/SemanticDataSerializationDBIntegrationTest.php')
-rw-r--r--SemanticMediaWiki/tests/phpunit/Integration/SemanticDataSerializationDBIntegrationTest.php68
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()
+ );
+ }
+
+}