diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Parser/LinksProcessorTest.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Parser/LinksProcessorTest.php | 139 |
1 files changed, 139 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Parser/LinksProcessorTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Parser/LinksProcessorTest.php new file mode 100644 index 00000000..f855bf18 --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Parser/LinksProcessorTest.php @@ -0,0 +1,139 @@ +<?php + +namespace SMW\Tests\Parser; + +use SMW\Parser\LinksProcessor; + +/** + * @covers \SMW\Parser\LinksProcessor + * @group semantic-mediawiki + * + * @license GNU GPL v2+ + * @since 2.5 + * + * @author mwjames + */ +class LinksProcessorTest extends \PHPUnit_Framework_TestCase { + + public function testCanConstruct() { + + $instance = new LinksProcessor(); + + $this->assertInstanceOf( + 'SMW\Parser\LinksProcessor', + $instance + ); + } + + /** + * @dataProvider semanticPreLinkProvider + */ + public function testPreprocess( $semanticLink, $expected ) { + + $instance = new LinksProcessor(); + + $this->assertEquals( + $expected, + $instance->preprocess( $semanticLink ) + ); + } + + /** + * @dataProvider semanticLinkProvider + */ + public function testProcess( $semanticLink, $expected ) { + + $instance = new LinksProcessor(); + + $this->assertEquals( + $expected, + $instance->process( $semanticLink ) + ); + } + + public function semanticPreLinkProvider() { + + $provider = []; + + $provider[] = [ + [ + '[[Foo::Bar]]', + 'Foo', + 'Bar' + ], + [ + '[[Foo::Bar]]', + 'Foo', + 'Bar' + ] + ]; + + $provider[] = [ + [ + '[[Foo::Bar|Foobar]]', + 'Foo', + 'Bar' + ], + [ + '[[Foo::Bar|Foobar]]', + 'Foo', + 'Bar' + ] + ]; + + return $provider; + } + + public function semanticLinkProvider() { + + $provider = []; + + $provider[] = [ + [ + '[[Foo::Bar]]', + 'Foo', + 'Bar' + ], + [ + [ + 'Foo' + ], + 'Bar', + false + ] + ]; + + $provider[] = [ + [ + '[[Foo::Bar|Foobar]]', + 'Foo', + 'Bar' + ], + [ + [ + 'Foo' + ], + 'Bar', + false + ] + ]; + + $provider[] = [ + [ + '[[Foo::=Bar|Foobar]]', + 'Foo', + '=Bar' + ], + [ + [ + 'Foo' + ], + '=Bar', + false + ] + ]; + + return $provider; + } + +} |