diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Exporter/ResourceBuilders/KeywordPropertyValueResourceBuilderTest.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Exporter/ResourceBuilders/KeywordPropertyValueResourceBuilderTest.php | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Exporter/ResourceBuilders/KeywordPropertyValueResourceBuilderTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Exporter/ResourceBuilders/KeywordPropertyValueResourceBuilderTest.php new file mode 100644 index 00000000..048212b3 --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Exporter/ResourceBuilders/KeywordPropertyValueResourceBuilderTest.php @@ -0,0 +1,81 @@ +<?php + +namespace SMW\Tests\Exporter\ResourceBuilders; + +use SMW\DataItemFactory; +use SMW\Exporter\Element\ExpNsResource; +use SMW\Exporter\ResourceBuilders\KeywordPropertyValueResourceBuilder; +use SMW\Tests\TestEnvironment; +use SMWExpData as ExpData; + +/** + * @covers \SMW\Exporter\ResourceBuilders\KeywordPropertyValueResourceBuilder + * @group semantic-mediawiki + * + * @license GNU GPL v2+ + * @since 2.5 + * + * @author mwjames + */ +class KeywordPropertyValueResourceBuilderTest extends \PHPUnit_Framework_TestCase { + + private $dataItemFactory; + private $testEnvironment; + + protected function setUp() { + parent::setUp(); + $this->dataItemFactory = new DataItemFactory(); + $this->testEnvironment = new TestEnvironment(); + + $this->testEnvironment->resetPoolCacheById( \SMWExporter::POOLCACHE_ID ); + } + + protected function tearDown() { + $this->testEnvironment->tearDown(); + parent::tearDown(); + } + + public function testCanConstruct() { + + $this->assertInstanceof( + KeywordPropertyValueResourceBuilder::class, + new KeywordPropertyValueResourceBuilder() + ); + } + + public function testIsNotResourceBuilderForNonExternalIdentifierTypedProperty() { + + $property = $this->dataItemFactory->newDIProperty( 'Foo' ); + + $instance = new KeywordPropertyValueResourceBuilder(); + + $this->assertFalse( + $instance->isResourceBuilderFor( $property ) + ); + } + + public function testAddResourceValueForValidProperty() { + + $property = $this->dataItemFactory->newDIProperty( 'Foo' ); + $property->setPropertyTypeId( '_keyw' ); + + $dataItem = $this->dataItemFactory->newDIBlob( 'Bar' ); + + $expData = new ExpData( + new ExpNsResource( 'Foobar', 'Bar', 'Mo', null ) + ); + + $instance = new KeywordPropertyValueResourceBuilder(); + + $instance->addResourceValue( + $expData, + $property, + $dataItem + ); + + $this->assertTrue( + $instance->isResourceBuilderFor( $property ) + ); + } + +} |