gplx/mediawiki/extensions/SemanticMediaWiki/tests/phpunit/Property/AnnotatorFactoryTest.php

151 lines
4.0 KiB
PHP

<?php
namespace SMW\Tests\Property;
use SMW\Property\AnnotatorFactory;
/**
* @covers \SMW\Property\AnnotatorFactory
* @group semantic-mediawiki
*
* @license GPL-2.0-or-later
* @since 2.0
*
* @author mwjames
*/
class AnnotatorFactoryTest extends \PHPUnit\Framework\TestCase {
public function testCanConstruct() {
$this->assertInstanceOf(
AnnotatorFactory::class,
new AnnotatorFactory()
);
}
public function testNewNullPropertyAnnotator() {
$semanticData = $this->getMockBuilder( '\SMW\SemanticData' )
->disableOriginalConstructor()
->getMock();
$instance = new AnnotatorFactory();
$this->assertInstanceOf(
'\SMW\Property\Annotators\NullPropertyAnnotator',
$instance->newNullPropertyAnnotator( $semanticData )
);
}
public function testNewRedirectPropertyAnnotator() {
$propertyAnnotator = $this->getMockBuilder( '\SMW\Property\Annotator' )
->disableOriginalConstructor()
->getMock();
$redirectTargetFinder = $this->getMockBuilder( '\SMW\MediaWiki\RedirectTargetFinder' )
->disableOriginalConstructor()
->getMock();
$instance = new AnnotatorFactory();
$this->assertInstanceOf(
'\SMW\Property\Annotators\RedirectPropertyAnnotator',
$instance->newRedirectPropertyAnnotator( $propertyAnnotator, $redirectTargetFinder )
);
}
public function testNewPredefinedPropertyAnnotator() {
$propertyAnnotator = $this->getMockBuilder( '\SMW\Property\Annotator' )
->disableOriginalConstructor()
->getMock();
$pageInfo = $this->getMockBuilder( '\SMW\PageInfo' )
->disableOriginalConstructor()
->getMock();
$instance = new AnnotatorFactory();
$this->assertInstanceOf(
'\SMW\Property\Annotators\PredefinedPropertyAnnotator',
$instance->newPredefinedPropertyAnnotator( $propertyAnnotator, $pageInfo )
);
}
public function testNewSortKeyPropertyAnnotator() {
$propertyAnnotator = $this->getMockBuilder( '\SMW\Property\Annotator' )
->disableOriginalConstructor()
->getMock();
$instance = new AnnotatorFactory();
$this->assertInstanceOf(
'\SMW\Property\Annotators\SortKeyPropertyAnnotator',
$instance->newSortKeyPropertyAnnotator( $propertyAnnotator, 'Foo' )
);
}
public function testNewTranslationPropertyAnnotator() {
$propertyAnnotator = $this->getMockBuilder( '\SMW\Property\Annotator' )
->disableOriginalConstructor()
->getMock();
$instance = new AnnotatorFactory();
$this->assertInstanceOf(
'\SMW\Property\Annotators\TranslationPropertyAnnotator',
$instance->newTranslationPropertyAnnotator( $propertyAnnotator, [] )
);
}
public function testNewCategoryPropertyAnnotator() {
$propertyAnnotator = $this->getMockBuilder( '\SMW\Property\Annotator' )
->disableOriginalConstructor()
->getMock();
$instance = new AnnotatorFactory();
$this->assertInstanceOf(
'\SMW\Property\Annotators\CategoryPropertyAnnotator',
$instance->newCategoryPropertyAnnotator( $propertyAnnotator, [] )
);
}
public function testCanConstructMandatoryTypePropertyAnnotator() {
$propertyAnnotator = $this->getMockBuilder( '\SMW\Property\Annotator' )
->disableOriginalConstructor()
->getMock();
$instance = new AnnotatorFactory();
$this->assertInstanceOf(
'\SMW\Property\Annotators\MandatoryTypePropertyAnnotator',
$instance->newMandatoryTypePropertyAnnotator( $propertyAnnotator )
);
}
public function testCanConstructSchemaPropertyAnnotator() {
$propertyAnnotator = $this->getMockBuilder( '\SMW\Property\Annotator' )
->disableOriginalConstructor()
->getMock();
$instance = new AnnotatorFactory();
$this->assertInstanceOf(
'\SMW\Property\Annotators\SchemaPropertyAnnotator',
$instance->newSchemaPropertyAnnotator( $propertyAnnotator )
);
}
public function testCanConstructAttachmentLinkPropertyAnnotator() {
$propertyAnnotator = $this->getMockBuilder( '\SMW\Property\Annotator' )
->disableOriginalConstructor()
->getMock();
$instance = new AnnotatorFactory();
$this->assertInstanceOf(
'\SMW\Property\Annotators\AttachmentLinkPropertyAnnotator',
$instance->newAttachmentLinkPropertyAnnotator( $propertyAnnotator )
);
}
}