diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/PrintRequestFactoryTest.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/PrintRequestFactoryTest.php | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/PrintRequestFactoryTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/PrintRequestFactoryTest.php new file mode 100644 index 00000000..4174bb97 --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Query/PrintRequestFactoryTest.php @@ -0,0 +1,88 @@ +<?php + +namespace SMW\Tests\Query; + +use SMW\DIProperty; +use SMW\Query\PrintRequest; +use SMW\Query\PrintRequestFactory; + +/** + * @covers \SMW\Query\PrintRequestFactory + * @group semantic-mediawiki + * + * @license GNU GPL v2+ + * @since 2.1 + * + * @author mwjames + */ +class PrintRequestFactoryTest extends \PHPUnit_Framework_TestCase { + + public function testCanConstruct() { + + $this->assertInstanceOf( + '\SMW\Query\PrintRequestFactory', + new PrintRequestFactory() + ); + } + + public function testCanConstructPrintRequestFromProperty() { + + $instance = new PrintRequestFactory(); + + $printRequest = $instance->newFromProperty( + new DIProperty( 'Foo' ) + ); + + $this->assertInstanceOf( + '\SMW\Query\PrintRequest', + $printRequest + ); + + $this->assertEquals( + 'Foo', + $printRequest->getLabel() + ); + } + + public function testCanConstructPrintRequestFromText() { + + $instance = new PrintRequestFactory(); + + $printRequest = $instance->newFromText( + 'Foo' + ); + + $this->assertInstanceOf( + '\SMW\Query\PrintRequest', + $printRequest + ); + } + + public function testPrintRequestFromTextToReturnNullOnInvalidText() { + + $instance = new PrintRequestFactory(); + + $printRequest = $instance->newFromText( + '--[[Foo', + false + ); + + $this->assertNull( + $printRequest + ); + } + + public function testCanConstructThisPrintRequest() { + + $instance = new PrintRequestFactory(); + + $printRequest = $instance->newThisPrintRequest( + 'Foo' + ); + + $this->assertTrue( + $printRequest->isMode( PrintRequest::PRINT_THIS ) + ); + } + +} |