1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\Tests\Query\Language; |
4
|
|
|
|
5
|
|
|
use SMW\DIWikiPage; |
6
|
|
|
use SMW\Localizer; |
7
|
|
|
use SMW\Query\Language\ConceptDescription; |
8
|
|
|
use SMW\Query\Language\ThingDescription; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @covers \SMW\Query\Language\ConceptDescription |
12
|
|
|
* @group semantic-mediawiki |
13
|
|
|
* |
14
|
|
|
* @license GNU GPL v2+ |
15
|
|
|
* @since 2.1 |
16
|
|
|
* |
17
|
|
|
* @author mwjames |
18
|
|
|
*/ |
19
|
|
|
class ConceptDescriptionTest extends \PHPUnit_Framework_TestCase { |
20
|
|
|
|
21
|
|
|
public function testCanConstruct() { |
22
|
|
|
|
23
|
|
|
$concept = $this->getMockBuilder( '\SMW\DIWikiPage' ) |
24
|
|
|
->disableOriginalConstructor() |
25
|
|
|
->getMock(); |
26
|
|
|
|
27
|
|
|
$this->assertInstanceOf( |
28
|
|
|
'SMW\Query\Language\ConceptDescription', |
29
|
|
|
new ConceptDescription( $concept ) |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
// Legacy |
33
|
|
|
$this->assertInstanceOf( |
34
|
|
|
'SMW\Query\Language\ConceptDescription', |
35
|
|
|
new \SMWConceptDescription( $concept ) |
36
|
|
|
); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testCommonMethods() { |
40
|
|
|
|
41
|
|
|
$ns = Localizer::getInstance()->getNamespaceTextById( SMW_NS_CONCEPT ); |
42
|
|
|
|
43
|
|
|
$concept = new DIWikiPage( 'Foo', SMW_NS_CONCEPT ); |
44
|
|
|
$instance = new ConceptDescription( $concept ); |
45
|
|
|
|
46
|
|
|
$this->assertEquals( $concept, $instance->getConcept() ); |
47
|
|
|
|
48
|
|
|
$this->assertEquals( "[[{$ns}:Foo]]", $instance->getQueryString() ); |
49
|
|
|
$this->assertEquals( " <q>[[{$ns}:Foo]]</q> ", $instance->getQueryString( true ) ); |
50
|
|
|
|
51
|
|
|
$this->assertEquals( false, $instance->isSingleton() ); |
52
|
|
|
$this->assertEquals( array(), $instance->getPrintRequests() ); |
53
|
|
|
|
54
|
|
|
$this->assertEquals( 1, $instance->getSize() ); |
55
|
|
|
$this->assertEquals( 0, $instance->getDepth() ); |
56
|
|
|
$this->assertEquals( 4, $instance->getQueryFeatures() ); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function testGetFingerprint() { |
60
|
|
|
|
61
|
|
|
$instance = new ConceptDescription( |
62
|
|
|
new DIWikiPage( 'Foo', SMW_NS_CONCEPT ) |
63
|
|
|
); |
64
|
|
|
|
65
|
|
|
$expected = $instance->getFingerprint(); |
66
|
|
|
|
67
|
|
|
$instance = new ConceptDescription( |
68
|
|
|
new DIWikiPage( 'Bar', SMW_NS_CONCEPT ) |
69
|
|
|
); |
70
|
|
|
|
71
|
|
|
$this->assertNotSame( |
72
|
|
|
$expected, |
73
|
|
|
$instance->getFingerprint() |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function testPrune() { |
78
|
|
|
|
79
|
|
|
$instance = new ConceptDescription( new DIWikiPage( 'Foo', SMW_NS_CONCEPT ) ); |
80
|
|
|
|
81
|
|
|
$maxsize = 1; |
82
|
|
|
$maxDepth = 1; |
83
|
|
|
$log = array(); |
84
|
|
|
|
85
|
|
|
$this->assertEquals( |
86
|
|
|
$instance, |
87
|
|
|
$instance->prune( $maxsize, $maxDepth, $log ) |
88
|
|
|
); |
89
|
|
|
|
90
|
|
|
$maxsize = 0; |
91
|
|
|
$maxDepth = 1; |
92
|
|
|
$log = array(); |
93
|
|
|
|
94
|
|
|
$this->assertEquals( |
95
|
|
|
new ThingDescription(), |
96
|
|
|
$instance->prune( $maxsize, $maxDepth, $log ) |
97
|
|
|
); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
} |
101
|
|
|
|