diff options
Diffstat (limited to 'SemanticMediaWiki/tests/phpunit/includes/serializer/SemanticDataSerializerTest.php')
-rw-r--r-- | SemanticMediaWiki/tests/phpunit/includes/serializer/SemanticDataSerializerTest.php | 117 |
1 files changed, 0 insertions, 117 deletions
diff --git a/SemanticMediaWiki/tests/phpunit/includes/serializer/SemanticDataSerializerTest.php b/SemanticMediaWiki/tests/phpunit/includes/serializer/SemanticDataSerializerTest.php deleted file mode 100644 index acfabd16..00000000 --- a/SemanticMediaWiki/tests/phpunit/includes/serializer/SemanticDataSerializerTest.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php - -namespace SMW\Tests\Serializers; - -use SMW\Serializers\SemanticDataSerializer; - -use SMW\Tests\Util\SemanticDataFactory; - -use SMW\DataValueFactory; -use SMw\SemanticData; -use SMW\DIWikiPage; -use SMW\Subobject; - -use Title; - -/** - * @covers \SMW\Serializers\SemanticDataSerializer - * - * @ingroup Test - * - * @group SMW - * @group SMWExtension - * - * @license GNU GPL v2+ - * @since 1.9 - * - * @author mwjames - */ -class SemanticDataSerializerTest extends \PHPUnit_Framework_TestCase { - - private $dataValueFactory; - private $semanticDataFactory; - - public function testCanConstructor() { - - $this->assertInstanceOf( - '\SMW\Serializers\SemanticDataSerializer', - new SemanticDataSerializer() - ); - } - - public function testInvalidSerializerObjectThrowsException() { - - $this->setExpectedException( 'OutOfBoundsException' ); - - $instance = new SemanticDataSerializer(); - $instance->serialize( 'Foo' ); - } - - /** - * @dataProvider semanticDataProvider - */ - public function testSerializerDeserializerRountrip( $data ) { - - $instance = new SemanticDataSerializer(); - - $this->assertInternalType( - 'array', - $instance->serialize( $data ) - ); - } - - public function semanticDataProvider() { - - $this->semanticDataFactory = new SemanticDataFactory(); - $this->dataValueFactory = DataValueFactory::getInstance(); - - $title = Title::newFromText( 'Foo' ); - - #0 Empty container - $foo = $this->semanticDataFactory->setSubject( DIWikiPage::newFromTitle( $title ) )->newEmptySemanticData(); - $provider[] = array( $foo ); - - #1 Single entry - $foo = $this->semanticDataFactory->setSubject( DIWikiPage::newFromTitle( $title ) )->newEmptySemanticData(); - $foo->addDataValue( $this->dataValueFactory->newPropertyValue( 'Has fooQuex', 'Bar' ) ); - $provider[] = array( $foo ); - - // #2 Single + single subobject entry - $foo = $this->semanticDataFactory->setSubject( DIWikiPage::newFromTitle( $title ) )->newEmptySemanticData(); - $foo->addDataValue( $this->dataValueFactory->newPropertyValue( 'Has fooQuex', 'Bar' ) ); - - $subobject = new Subobject( $title ); - $subobject->setSemanticData( 'Foo' ); - $subobject->addDataValue( $this->dataValueFactory->newPropertyValue( 'Has subobjects', 'Bam' ) ); - - $foo->addPropertyObjectValue( - $subobject->getProperty(), - $subobject->getContainer() - ); - - $provider[] = array( $foo ); - - #3 Multiple entries - $foo = $this->semanticDataFactory->setSubject( DIWikiPage::newFromTitle( $title ) )->newEmptySemanticData(); - $foo->addDataValue( $this->dataValueFactory->newPropertyValue( 'Has fooQuex', 'Bar' ) ); - $foo->addDataValue( $this->dataValueFactory->newPropertyValue( 'Has queez', 'Xeey' ) ); - - $subobject = new Subobject( $title ); - $subobject->setSemanticData( 'Foo' ); - $subobject->addDataValue( $this->dataValueFactory->newPropertyValue( 'Has subobjects', 'Bam' ) ); - $subobject->addDataValue( $this->dataValueFactory->newPropertyValue( 'Has fooQuex', 'Fuz' ) ); - - $subobject->setSemanticData( 'Bar' ); - $subobject->addDataValue( $this->dataValueFactory->newPropertyValue( 'Has fooQuex', 'Fuz' ) ); - - $foo->addPropertyObjectValue( - $subobject->getProperty(), - $subobject->getContainer() - ); - - $provider[] = array( $foo ); - - return $provider; - } - -} |