summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/PropertyAnnotatorFactoryTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/PropertyAnnotatorFactoryTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/PropertyAnnotatorFactoryTest.php146
1 files changed, 146 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/PropertyAnnotatorFactoryTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/PropertyAnnotatorFactoryTest.php
new file mode 100644
index 00000000..11a9d7ab
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/PropertyAnnotatorFactoryTest.php
@@ -0,0 +1,146 @@
+<?php
+
+namespace SMW\Tests;
+
+use SMW\PropertyAnnotatorFactory;
+
+/**
+ * @covers \SMW\PropertyAnnotatorFactory
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @since 2.0
+ *
+ * @author mwjames
+ */
+class PropertyAnnotatorFactoryTest extends \PHPUnit_Framework_TestCase {
+
+ public function testCanConstruct() {
+
+ $this->assertInstanceOf(
+ '\SMW\PropertyAnnotatorFactory',
+ new PropertyAnnotatorFactory()
+ );
+ }
+
+ public function testNewNullPropertyAnnotator() {
+
+ $semanticData = $this->getMockBuilder( '\SMW\SemanticData' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $instance = new PropertyAnnotatorFactory();
+
+ $this->assertInstanceOf(
+ '\SMW\PropertyAnnotators\NullPropertyAnnotator',
+ $instance->newNullPropertyAnnotator( $semanticData )
+ );
+ }
+
+ public function testNewRedirectPropertyAnnotator() {
+
+ $propertyAnnotator = $this->getMockBuilder( '\SMW\PropertyAnnotator' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $redirectTargetFinder = $this->getMockBuilder( '\SMW\MediaWiki\RedirectTargetFinder' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $instance = new PropertyAnnotatorFactory();
+
+ $this->assertInstanceOf(
+ '\SMW\PropertyAnnotators\RedirectPropertyAnnotator',
+ $instance->newRedirectPropertyAnnotator( $propertyAnnotator, $redirectTargetFinder )
+ );
+ }
+
+ public function testNewPredefinedPropertyAnnotator() {
+
+ $propertyAnnotator = $this->getMockBuilder( '\SMW\PropertyAnnotator' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $pageInfo = $this->getMockBuilder( '\SMW\PageInfo' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $instance = new PropertyAnnotatorFactory();
+
+ $this->assertInstanceOf(
+ '\SMW\PropertyAnnotators\PredefinedPropertyAnnotator',
+ $instance->newPredefinedPropertyAnnotator( $propertyAnnotator, $pageInfo )
+ );
+ }
+
+ public function testNewSortKeyPropertyAnnotator() {
+
+ $propertyAnnotator = $this->getMockBuilder( '\SMW\PropertyAnnotator' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $instance = new PropertyAnnotatorFactory();
+
+ $this->assertInstanceOf(
+ '\SMW\PropertyAnnotators\SortKeyPropertyAnnotator',
+ $instance->newSortKeyPropertyAnnotator( $propertyAnnotator, 'Foo' )
+ );
+ }
+
+ public function testNewTranslationPropertyAnnotator() {
+
+ $propertyAnnotator = $this->getMockBuilder( '\SMW\PropertyAnnotator' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $instance = new PropertyAnnotatorFactory();
+
+ $this->assertInstanceOf(
+ '\SMW\PropertyAnnotators\TranslationPropertyAnnotator',
+ $instance->newTranslationPropertyAnnotator( $propertyAnnotator, [] )
+ );
+ }
+
+ public function testNewCategoryPropertyAnnotator() {
+
+ $propertyAnnotator = $this->getMockBuilder( '\SMW\PropertyAnnotator' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $instance = new PropertyAnnotatorFactory();
+
+ $this->assertInstanceOf(
+ '\SMW\PropertyAnnotators\CategoryPropertyAnnotator',
+ $instance->newCategoryPropertyAnnotator( $propertyAnnotator, [] )
+ );
+ }
+
+ public function testCanConstructMandatoryTypePropertyAnnotator() {
+
+ $propertyAnnotator = $this->getMockBuilder( '\SMW\PropertyAnnotator' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $instance = new PropertyAnnotatorFactory();
+
+ $this->assertInstanceOf(
+ '\SMW\PropertyAnnotators\MandatoryTypePropertyAnnotator',
+ $instance->newMandatoryTypePropertyAnnotator( $propertyAnnotator )
+ );
+ }
+
+ public function testCanConstructSchemaPropertyAnnotator() {
+
+ $propertyAnnotator = $this->getMockBuilder( '\SMW\PropertyAnnotator' )
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $instance = new PropertyAnnotatorFactory();
+
+ $this->assertInstanceOf(
+ '\SMW\PropertyAnnotators\SchemaPropertyAnnotator',
+ $instance->newSchemaPropertyAnnotator( $propertyAnnotator )
+ );
+ }
+
+}