1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\Tests; |
4
|
|
|
|
5
|
|
|
use SMW\PropertyAnnotatorFactory; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @covers \SMW\PropertyAnnotatorFactory |
9
|
|
|
* @group semantic-mediawiki |
10
|
|
|
* |
11
|
|
|
* @license GNU GPL v2+ |
12
|
|
|
* @since 2.0 |
13
|
|
|
* |
14
|
|
|
* @author mwjames |
15
|
|
|
*/ |
16
|
|
|
class PropertyAnnotatorFactoryTest extends \PHPUnit_Framework_TestCase { |
17
|
|
|
|
18
|
|
|
public function testCanConstruct() { |
19
|
|
|
|
20
|
|
|
$this->assertInstanceOf( |
21
|
|
|
'\SMW\PropertyAnnotatorFactory', |
22
|
|
|
new PropertyAnnotatorFactory() |
23
|
|
|
); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testNewNullPropertyAnnotator() { |
27
|
|
|
|
28
|
|
|
$semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
29
|
|
|
->disableOriginalConstructor() |
30
|
|
|
->getMock(); |
31
|
|
|
|
32
|
|
|
$instance = new PropertyAnnotatorFactory(); |
33
|
|
|
|
34
|
|
|
$this->assertInstanceOf( |
35
|
|
|
'\SMW\PropertyAnnotator\NullPropertyAnnotator', |
36
|
|
|
$instance->newNullPropertyAnnotator( $semanticData ) |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testNewRedirectPropertyAnnotator() { |
41
|
|
|
|
42
|
|
|
$semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
43
|
|
|
->disableOriginalConstructor() |
44
|
|
|
->getMock(); |
45
|
|
|
|
46
|
|
|
$redirectTargetFinder = $this->getMockBuilder( '\SMW\MediaWiki\RedirectTargetFinder' ) |
47
|
|
|
->disableOriginalConstructor() |
48
|
|
|
->getMock(); |
49
|
|
|
|
50
|
|
|
$instance = new PropertyAnnotatorFactory(); |
51
|
|
|
|
52
|
|
|
$this->assertInstanceOf( |
53
|
|
|
'\SMW\PropertyAnnotator\RedirectPropertyAnnotator', |
54
|
|
|
$instance->newRedirectPropertyAnnotator( $semanticData, $redirectTargetFinder ) |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testNewPredefinedPropertyAnnotator() { |
59
|
|
|
|
60
|
|
|
$semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
61
|
|
|
->disableOriginalConstructor() |
62
|
|
|
->getMock(); |
63
|
|
|
|
64
|
|
|
$pageInfo = $this->getMockBuilder( '\SMW\PageInfo' ) |
65
|
|
|
->disableOriginalConstructor() |
66
|
|
|
->getMock(); |
67
|
|
|
|
68
|
|
|
$instance = new PropertyAnnotatorFactory(); |
69
|
|
|
|
70
|
|
|
$this->assertInstanceOf( |
71
|
|
|
'\SMW\PropertyAnnotator\PredefinedPropertyAnnotator', |
72
|
|
|
$instance->newPredefinedPropertyAnnotator( $semanticData, $pageInfo ) |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function testNewSortKeyPropertyAnnotator() { |
77
|
|
|
|
78
|
|
|
$semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
79
|
|
|
->disableOriginalConstructor() |
80
|
|
|
->getMock(); |
81
|
|
|
|
82
|
|
|
$instance = new PropertyAnnotatorFactory(); |
83
|
|
|
|
84
|
|
|
$this->assertInstanceOf( |
85
|
|
|
'\SMW\PropertyAnnotator\SortKeyPropertyAnnotator', |
86
|
|
|
$instance->newSortKeyPropertyAnnotator( $semanticData, 'Foo' ) |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function testNewCategoryPropertyAnnotator() { |
91
|
|
|
|
92
|
|
|
$semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
93
|
|
|
->disableOriginalConstructor() |
94
|
|
|
->getMock(); |
95
|
|
|
|
96
|
|
|
$instance = new PropertyAnnotatorFactory(); |
97
|
|
|
|
98
|
|
|
$this->assertInstanceOf( |
99
|
|
|
'\SMW\PropertyAnnotator\CategoryPropertyAnnotator', |
100
|
|
|
$instance->newCategoryPropertyAnnotator( $semanticData, array() ) |
101
|
|
|
); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function testCanConstructMandatoryTypePropertyAnnotator() { |
105
|
|
|
|
106
|
|
|
$semanticData = $this->getMockBuilder( '\SMW\SemanticData' ) |
107
|
|
|
->disableOriginalConstructor() |
108
|
|
|
->getMock(); |
109
|
|
|
|
110
|
|
|
$instance = new PropertyAnnotatorFactory(); |
111
|
|
|
|
112
|
|
|
$this->assertInstanceOf( |
113
|
|
|
'\SMW\PropertyAnnotator\MandatoryTypePropertyAnnotator', |
114
|
|
|
$instance->newMandatoryTypePropertyAnnotator( $semanticData ) |
115
|
|
|
); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
} |
119
|
|
|
|