diff options
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/QueryResultTest.php')
-rw-r--r-- | www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/QueryResultTest.php | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/QueryResultTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/QueryResultTest.php new file mode 100644 index 00000000..61e74563 --- /dev/null +++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/includes/storage/QueryResultTest.php @@ -0,0 +1,131 @@ +<?php + +namespace SMW\Tests; + +use SMW\DIWikiPage; +use SMWQueryResult as QueryResult; + +/** + * @covers \SMWQueryResult + * + * @group SMW + * @group SMWExtension + * + * @license GNU GPL v2+ + * @since 2.1 + * + * @author mwjames + */ +class QueryResultTest extends \PHPUnit_Framework_TestCase { + + public function testCanConstruct() { + + $query = $this->getMockBuilder( '\SMWQuery' ) + ->disableOriginalConstructor() + ->getMock(); + + $store = $this->getMockBuilder( '\SMW\Store' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $printRequests = []; + $results = []; + + $this->assertInstanceOf( + '\SMWQueryResult', + new QueryResult( $printRequests, $query, $results, $store ) + ); + } + + public function testVerifyThatAfterSerializeToArrayResultNextCanBeUsed() { + + $query = $this->getMockBuilder( '\SMWQuery' ) + ->disableOriginalConstructor() + ->getMock(); + + $store = $this->getMockBuilder( '\SMW\Store' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $printRequests = []; + + $results = [ + new DIWikiPage( 'Foo', 0 ), + new DIWikiPage( 'Bar', 0 ) + ]; + + $instance = new QueryResult( $printRequests, $query, $results, $store ); + + $instance->serializeToArray(); + + $this->assertInternalType( + 'array', + $instance->getNext() + ); + + $instance->getHash(); + + $this->assertInternalType( + 'array', + $instance->getNext() + ); + } + + public function testIsFromCache() { + + $query = $this->getMockBuilder( '\SMWQuery' ) + ->disableOriginalConstructor() + ->getMock(); + + $store = $this->getMockBuilder( '\SMW\Store' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $printRequests = []; + $results = []; + + $instance = new QueryResult( + $printRequests, + $query, + $results, + $store + ); + + $this->assertFalse( + $instance->isFromCache() + ); + + $instance->setFromCache( true ); + + $this->assertTrue( + $instance->isFromCache() + ); + } + + public function testGetHash() { + + $query = $this->getMockBuilder( '\SMWQuery' ) + ->disableOriginalConstructor() + ->getMock(); + + $store = $this->getMockBuilder( '\SMW\Store' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $printRequests = []; + $results = []; + + $instance = new QueryResult( + $printRequests, + $query, + $results, + $store + ); + + $this->assertNotSame( + $instance->getHash( 'quick' ), + $instance->getHash() + ); + } + +} |