diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/export/ExpDataTest.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/export/ExpDataTest.php | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/export/ExpDataTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/export/ExpDataTest.php new file mode 100644 index 00000000..42120707 --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/export/ExpDataTest.php @@ -0,0 +1,143 @@ +<?php + +namespace SMW\Tests\Exporter; + +use SMW\Exporter\Element\ExpLiteral; +use SMW\Exporter\Element\ExpNsResource; +use SMWExpData as ExpData; + +/** + * @covers \SMWExpData + * + * @group semantic-mediawiki + * + * @license GNU GPL v2+ + * @since 2.2 + * + * @author mwjames + */ +class ExpDataTest extends \PHPUnit_Framework_TestCase { + + public function testCanConstructor() { + + $expNsResource = $this->getMockBuilder( '\SMW\Exporter\Element\ExpNsResource' ) + ->disableOriginalConstructor() + ->getMock(); + + $this->assertInstanceOf( + '\SMWExpData', + new ExpData( $expNsResource ) + ); + } + + /** + * @dataProvider expDataHashProvider + */ + public function testGetHash( $expData, $expected ) { + + $this->assertEquals( + $expected, + $expData->getHash() + ); + } + + public function expDataHashProvider() { + + #0 + $expData = new ExpData( + new ExpNsResource( 'Foo', 'Bar', 'Mo', null ) + ); + + $provider[] = [ + $expData, + '4dc04c87e9660854a5609ff132175fd5' + ]; + + #1 + $expData = new ExpData( + new ExpNsResource( 'Foo', 'Bar', 'Mo', null ) + ); + + $expData->addPropertyObjectValue( + new ExpNsResource( 'Li', 'La', 'Lu', null ), + new ExpLiteral( 'Foo', 'Bar' ) + ); + + $provider[] = [ + $expData, + '5702e5e8c6145aaf8d89840a4a3b18c2' + ]; + + #2 + $expData = new ExpData( + new ExpNsResource( 'Foo', 'Bar', 'Mo', null ) + ); + + $expData->addPropertyObjectValue( + new ExpNsResource( 'Li', 'La', 'Lu', null ), + new ExpLiteral( 'Foo', 'Bar' ) + ); + + $expData->addPropertyObjectValue( + new ExpNsResource( 'Li', 'La', 'Lu', null ), + new ExpLiteral( 'Bar', 'Foo' ) + ); + + $provider[] = [ + $expData, + '13edcedd007979f5638fbc958f0cdaf8' + ]; + + #3 Same as 2 but different sorting/same hash + $expData = new ExpData( + new ExpNsResource( 'Foo', 'Bar', 'Mo', null ) + ); + + $expData->addPropertyObjectValue( + new ExpNsResource( 'Li', 'La', 'Lu', null ), + new ExpLiteral( 'Bar', 'Foo' ) + ); + + $expData->addPropertyObjectValue( + new ExpNsResource( 'Li', 'La', 'Lu', null ), + new ExpLiteral( 'Foo', 'Bar' ) + ); + + $provider[] = [ + $expData, + '13edcedd007979f5638fbc958f0cdaf8' + ]; + + #4 Nesting + $expDataLevel2 = new ExpData( + new ExpNsResource( 'Foo', 'Bar', 'Mo', null ) + ); + + $expDataLevel2->addPropertyObjectValue( + new ExpNsResource( 'Li', 'La', 'Lu', null ), + new ExpLiteral( 'Foo', 'Bar' ) + ); + + $expData = new ExpData( + new ExpNsResource( 'Foo', 'Bar', 'Mo', null ) + ); + + $expData->addPropertyObjectValue( + new ExpNsResource( 'Li', 'La', 'Lu', null ), + new ExpLiteral( 'Foo', 'Bar' ) + ); + + $expData->addPropertyObjectValue( + new ExpNsResource( 'Li', 'La', 'Lu', null ), + $expDataLevel2 + ); + + $provider[] = [ + $expData, + 'e684e7640a201d2d33e035aaa866c1ac' + ]; + + return $provider; + } + +} |