diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/ExcerptsTest.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/ExcerptsTest.php | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/ExcerptsTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/ExcerptsTest.php new file mode 100644 index 00000000..9dae22ae --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/ExcerptsTest.php @@ -0,0 +1,72 @@ +<?php + +namespace SMW\Tests\Query; + +use SMW\DIWikiPage; +use SMW\Query\Excerpts; + +/** + * @covers \SMW\Query\Excerpts + * @group semantic-mediawiki + * + * @license GNU GPL v2+ + * @since 3.0 + * + * @author mwjames + */ +class ExcerptsTest extends \PHPUnit_Framework_TestCase { + + public function testCanConstruct() { + + $this->assertInstanceOf( + Excerpts::class, + new Excerpts() + ); + } + + public function testAddExcerpt() { + + $instance = new Excerpts(); + + $instance->addExcerpt( 'Foo', 0.1 ); + + $this->assertEquals( + 0.1, + $instance->getExcerpt( 'Foo' ) + ); + + $this->assertFalse( + $instance->getExcerpt( 'Bar' ) + ); + } + + public function testAddExcerpt_DIWikiPage() { + + $dataItem = DIWikiPage::newFromText( 'Bar' ); + $instance = new Excerpts(); + + $instance->addExcerpt( $dataItem, 10 ); + + $this->assertEquals( + 10, + $instance->getExcerpt( $dataItem ) + ); + } + + public function testGetExcerpts() { + + $instance = new Excerpts(); + + $instance->addExcerpt( 'Foo', '...' ); + $instance->addExcerpt( 'Bar', 1001 ); + + $this->assertEquals( + [ + [ 'Foo', '...' ], + [ 'Bar', 1001 ] + ], + $instance->getExcerpts() + ); + } + +} |