jenkins-bot has submitted this change and it was merged.
Change subject: SMW\DataValueFactoryTest add assertion
......................................................................
SMW\DataValueFactoryTest add assertion
Change-Id: Idebd79afa58db00a4edb2e99315c84a5ef3d91f8
---
M includes/DataValueFactory.php
M tests/phpunit/includes/DataValueFactoryTest.php
2 files changed, 62 insertions(+), 0 deletions(-)
Approvals:
Mwjames: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/DataValueFactory.php b/includes/DataValueFactory.php
index e490460..289d123 100644
--- a/includes/DataValueFactory.php
+++ b/includes/DataValueFactory.php
@@ -6,6 +6,8 @@
use SMWErrorValue;
use SMWDIProperty;
use SMWPropertyValue;
+use SMWDIWikiPage;
+use SMWDIError;
/**
* This file contains the SMWDataValueFactory class.
diff --git a/tests/phpunit/includes/DataValueFactoryTest.php
b/tests/phpunit/includes/DataValueFactoryTest.php
index 9be3895..cc0ae11 100644
--- a/tests/phpunit/includes/DataValueFactoryTest.php
+++ b/tests/phpunit/includes/DataValueFactoryTest.php
@@ -6,6 +6,9 @@
use SMWDataItem;
use SMWPropertyValue;
+use Title;
+use SMWDIWikiPage;
+
/**
* Tests for the SMW\DataValueFactory class
*
@@ -44,6 +47,45 @@
* @ingroup Test
*/
class DataValueFactoryTest extends \MediaWikiTestCase {
+
+ /**
+ * Helper method that returns a random string
+ *
+ * @since 1.9
+ *
+ * @param $length
+ *
+ * @return string
+ */
+ private function getRandomString( $length = 10 ) {
+ return substr( str_shuffle(
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ), 0, $length
);
+ }
+
+ /**
+ * Helper method to get Title object
+ *
+ * @since 1.9
+ *
+ * @param $namespace
+ *
+ * @return Title
+ */
+ private function getTitle( $namespace = NS_MAIN ){
+ return Title::newFromText( $this->getRandomString(), $namespace
);
+ }
+
+ /**
+ * Helper method that returns a SMWDIWikiPage object
+ *
+ * @since 1.9
+ *
+ * @param $namespace
+ *
+ * @return \SMWDIWikiPage
+ */
+ public function getSubject( $namespace = NS_MAIN ) {
+ return SMWDIWikiPage::newFromTitle( $this->getTitle( $namespace
) );
+ }
/**
* DataProvider
@@ -176,6 +218,15 @@
} else {
$this->assertInternalType( 'array',
$dataValue->getErrors() );
}
+
+ // Check interface parameters
+ $dataValue = DataValueFactory::newPropertyObjectValue(
+ $propertyDI,
+ $value,
+ $this->getRandomString(),
+ $this->getSubject()
+ );
+ $this->assertInstanceOf( $expectedInstance , $dataValue );
}
/**
@@ -222,6 +273,15 @@
} else {
$this->assertInternalType( 'array',
$dataValue->getErrors() );
}
+
+ // Check interface parameters
+ $dataValue = DataValueFactory::newPropertyValue(
+ $propertyName,
+ $value,
+ $this->getRandomString(),
+ $this->getSubject()
+ );
+ $this->assertInstanceOf( $expectedInstance , $dataValue );
}
/**
--
To view, visit https://gerrit.wikimedia.org/r/60391
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idebd79afa58db00a4edb2e99315c84a5ef3d91f8
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/SemanticMediaWiki
Gerrit-Branch: master
Gerrit-Owner: Mwjames <[email protected]>
Gerrit-Reviewer: Mwjames <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits