summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Integration/Query/NullQueryResultTest.php
blob: 7e977e346cfa9271f0d188a36276f6efdd321637 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php

namespace SMW\Tests\Integration\Query;

use SMW\ApplicationFactory;
use SMW\DIWikiPage;
use SMW\Query\Language\Conjunction;
use SMW\Query\Language\Disjunction;
use SMW\Query\Language\NamespaceDescription;
use SMW\Query\Language\ValueDescription;
use SMWQuery as Query;

/**
 * @group SMW
 * @group SMWExtension
 *
 * @license GNU GPL v2+
 * @since 2.0
 *
 * @author mwjames
 */
class NullQueryResultTest extends \PHPUnit_Framework_TestCase {

	public function testNullQueryResult() {

		$term = '[[Some_string_to_query]]';

		$description = new ValueDescription(
			new DIWikiPage( $term, NS_MAIN ),
			null
		);

		$query = new Query(
			$description,
			false,
			false
		);

		$query->querymode = Query::MODE_INSTANCES;

		$description = $query->getDescription();

		$namespacesDisjunction = new Disjunction(
			array_map( function ( $ns ) {
				return new NamespaceDescription( $ns );
			}, [ NS_MAIN ] )
		);

		$description = new Conjunction( [ $description, $namespacesDisjunction ] );

		$query->setDescription( $description );

		$this->assertInstanceOf(
			'\SMWQueryResult',
			ApplicationFactory::getInstance()->getStore()->getQueryResult( $query )
		);
	}

}