summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/InSemanticDataFetcher.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/InSemanticDataFetcher.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/InSemanticDataFetcher.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/InSemanticDataFetcher.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/InSemanticDataFetcher.php
new file mode 100644
index 00000000..ccb50f8c
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/InSemanticDataFetcher.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace SMW\Tests\Utils;
+
+use SMW\DIWikiPage;
+use SMW\SemanticData;
+use SMW\Store;
+use SMWRequestOptions as RequestOptions;
+
+/**
+ *
+ * @group SMW
+ * @group SMWExtension
+ *
+ * @license GNU GPL v2+
+ * @since 2.0
+ *
+ * @author mwjames
+ */
+class InSemanticDataFetcher {
+
+ /**
+ * @var Store
+ */
+ private $store = null;
+
+ /**
+ * @since 2.0
+ *
+ * @param Store $store
+ */
+ public function __construct( Store $store ) {
+ $this->store = $store;
+ }
+
+ /**
+ * @since 2.0
+ *
+ * @return SemanticData
+ */
+ public function getSemanticData( DIWikiPage $subject ) {
+
+ $requestOptions = new RequestOptions();
+ $requestOptions->sort = true;
+
+ $semanticData = new SemanticData( $subject );
+
+ $incomingProperties = $this->store->getInProperties( $subject, $requestOptions );
+
+ foreach ( $incomingProperties as $property ) {
+ $values = $this->store->getPropertySubjects( $property, null );
+
+ foreach ( $values as $value ) {
+ $semanticData->addPropertyObjectValue( $property, $value );
+ }
+ }
+
+ return $semanticData;
+ }
+
+}