1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SMW\Tests\SQLStore; |
4
|
|
|
|
5
|
|
|
use SMW\SQLStore\SQLStoreFactory; |
6
|
|
|
use SMW\Store; |
7
|
|
|
use SMWSQLStore3; |
8
|
|
|
use SMW\Tests\TestEnvironment; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @covers \SMW\SQLStore\SQLStoreFactory |
12
|
|
|
* @group semantic-mediawiki |
13
|
|
|
* |
14
|
|
|
* @license GNU GPL v2+ |
15
|
|
|
* @since 2.2 |
16
|
|
|
* |
17
|
|
|
* @author Jeroen De Dauw < [email protected] > |
18
|
|
|
*/ |
19
|
|
|
class SQLStoreFactoryTest extends \PHPUnit_Framework_TestCase { |
20
|
|
|
|
21
|
|
|
private $store; |
22
|
|
|
private $testEnvironment; |
23
|
|
|
|
24
|
|
|
protected function setUp() { |
25
|
|
|
parent::setUp(); |
26
|
|
|
|
27
|
|
|
$this->testEnvironment = new TestEnvironment(); |
28
|
|
|
|
29
|
|
|
$this->store = $this->getMockBuilder( '\SMWSQLStore3' ) |
30
|
|
|
->disableOriginalConstructor() |
31
|
|
|
->getMock(); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testCanConstruct() { |
35
|
|
|
|
36
|
|
|
$this->assertInstanceOf( |
37
|
|
|
'\SMW\SQLStore\SQLStoreFactory', |
38
|
|
|
new SQLStoreFactory( $this->store ) |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testNewSlaveQueryEngineReturnType() { |
43
|
|
|
|
44
|
|
|
$instance = new SQLStoreFactory( new SMWSQLStore3() ); |
45
|
|
|
|
46
|
|
|
$this->assertInstanceOf( |
47
|
|
|
'\SMW\SQLStore\QueryEngine\QueryEngine', |
48
|
|
|
$instance->newSlaveQueryEngine() |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function testNewMasterQueryEngineReturnType() { |
53
|
|
|
|
54
|
|
|
$instance = new SQLStoreFactory( new SMWSQLStore3() ); |
55
|
|
|
|
56
|
|
|
$this->assertInstanceOf( |
57
|
|
|
'\SMW\SQLStore\QueryEngine\QueryEngine', |
58
|
|
|
$instance->newMasterQueryEngine() |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testNewMasterConceptCache() { |
63
|
|
|
|
64
|
|
|
$instance = new SQLStoreFactory( new SMWSQLStore3() ); |
65
|
|
|
|
66
|
|
|
$this->assertInstanceOf( |
67
|
|
|
'SMW\SQLStore\ConceptCache', |
68
|
|
|
$instance->newMasterConceptCache() |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function testNewSlaveConceptCache() { |
73
|
|
|
|
74
|
|
|
$instance = new SQLStoreFactory( new SMWSQLStore3() ); |
75
|
|
|
|
76
|
|
|
$this->assertInstanceOf( |
77
|
|
|
'SMW\SQLStore\ConceptCache', |
78
|
|
|
$instance->newSlaveConceptCache() |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function testCanConstractIdTableManager() { |
83
|
|
|
|
84
|
|
|
$instance = new SQLStoreFactory( new SMWSQLStore3() ); |
85
|
|
|
|
86
|
|
|
$this->assertInstanceOf( |
87
|
|
|
'SMWSql3SmwIds', |
88
|
|
|
$instance->newIdTableManager() |
89
|
|
|
); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function testCanConstructUsageStatisticsCachedListLookup() { |
93
|
|
|
|
94
|
|
|
$instance = new SQLStoreFactory( new SMWSQLStore3() ); |
95
|
|
|
|
96
|
|
|
$this->assertInstanceOf( |
97
|
|
|
'SMW\SQLStore\Lookup\CachedListLookup', |
98
|
|
|
$instance->newUsageStatisticsCachedListLookup() |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function testCanConstructPropertyUsageCachedListLookup() { |
103
|
|
|
|
104
|
|
|
$instance = new SQLStoreFactory( new SMWSQLStore3() ); |
105
|
|
|
|
106
|
|
|
$this->assertInstanceOf( |
107
|
|
|
'SMW\SQLStore\Lookup\CachedListLookup', |
108
|
|
|
$instance->newPropertyUsageCachedListLookup( null ) |
109
|
|
|
); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function testCanConstructUnusedPropertyCachedListLookup() { |
113
|
|
|
|
114
|
|
|
$instance = new SQLStoreFactory( new SMWSQLStore3() ); |
115
|
|
|
|
116
|
|
|
$this->assertInstanceOf( |
117
|
|
|
'SMW\SQLStore\Lookup\CachedListLookup', |
118
|
|
|
$instance->newUnusedPropertyCachedListLookup( null ) |
119
|
|
|
); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function testCanConstructUndeclaredPropertyCachedListLookup() { |
123
|
|
|
|
124
|
|
|
$instance = new SQLStoreFactory( new SMWSQLStore3() ); |
125
|
|
|
|
126
|
|
|
$this->assertInstanceOf( |
127
|
|
|
'SMW\SQLStore\Lookup\CachedListLookup', |
128
|
|
|
$instance->newUndeclaredPropertyCachedListLookup( null, '_foo' ) |
|
|
|
|
129
|
|
|
); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function testCanConstructCachedListLookup() { |
133
|
|
|
|
134
|
|
|
$instance = new SQLStoreFactory( $this->store ); |
135
|
|
|
|
136
|
|
|
$listLookup = $this->getMockBuilder( '\SMW\SQLStore\Lookup\ListLookup' ) |
137
|
|
|
->disableOriginalConstructor() |
138
|
|
|
->getMock(); |
139
|
|
|
|
140
|
|
|
$this->assertInstanceOf( |
141
|
|
|
'SMW\SQLStore\Lookup\CachedListLookup', |
142
|
|
|
$instance->newCachedListLookup( $listLookup, true, 42 ) |
143
|
|
|
); |
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
public function testCanConstructRequestOptionsProcessor() { |
147
|
|
|
|
148
|
|
|
$instance = new SQLStoreFactory( $this->store ); |
149
|
|
|
|
150
|
|
|
$this->assertInstanceOf( |
151
|
|
|
'\SMW\SQLStore\RequestOptionsProcessor', |
152
|
|
|
$instance->newRequestOptionsProcessor() |
153
|
|
|
); |
154
|
|
|
} |
155
|
|
|
|
156
|
|
|
public function testCanConstructEntityLookup() { |
157
|
|
|
|
158
|
|
|
$instance = new SQLStoreFactory( $this->store ); |
159
|
|
|
|
160
|
|
|
$this->testEnvironment->addConfiguration( 'smwgValueLookupFeatures', CACHE_NONE ); |
161
|
|
|
|
162
|
|
|
$this->assertInstanceOf( |
163
|
|
|
'SMW\SQLStore\EntityStore\DirectEntityLookup', |
164
|
|
|
$instance->newEntityLookup() |
165
|
|
|
); |
166
|
|
|
|
167
|
|
|
$this->testEnvironment->addConfiguration( 'smwgValueLookupFeatures', 'SomeCache' ); |
168
|
|
|
|
169
|
|
|
$this->assertInstanceOf( |
170
|
|
|
'SMW\SQLStore\EntityStore\PersistentCachedEntityLookup', |
171
|
|
|
$instance->newEntityLookup() |
172
|
|
|
); |
173
|
|
|
} |
174
|
|
|
|
175
|
|
|
public function testCanConstructPropertyTableIdReferenceFinder() { |
176
|
|
|
|
177
|
|
|
$instance = new SQLStoreFactory( $this->store ); |
178
|
|
|
|
179
|
|
|
$this->assertInstanceOf( |
180
|
|
|
'SMW\SQLStore\PropertyTableIdReferenceFinder', |
181
|
|
|
$instance->newPropertyTableIdReferenceFinder() |
182
|
|
|
); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
public function testCanConstructDataItemHandlerDispatcher() { |
186
|
|
|
|
187
|
|
|
$instance = new SQLStoreFactory( $this->store ); |
188
|
|
|
|
189
|
|
|
$this->assertInstanceOf( |
190
|
|
|
'SMW\SQLStore\EntityStore\DataItemHandlerDispatcher', |
191
|
|
|
$instance->newDataItemHandlerDispatcher() |
192
|
|
|
); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
public function testCanConstructDeferredCachedListLookupUpdate() { |
196
|
|
|
|
197
|
|
|
$instance = new SQLStoreFactory( $this->store ); |
198
|
|
|
|
199
|
|
|
$this->assertInstanceOf( |
200
|
|
|
'SMW\DeferredCallableUpdate', |
201
|
|
|
$instance->newDeferredCallableCachedListLookupUpdate() |
202
|
|
|
); |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
public function testCanConstructInstaller() { |
206
|
|
|
|
207
|
|
|
$connection = $this->getMockBuilder( '\DatabaseBase' ) |
208
|
|
|
->disableOriginalConstructor() |
209
|
|
|
->getMockForAbstractClass(); |
210
|
|
|
|
211
|
|
|
$connection->expects( $this->any() ) |
212
|
|
|
->method( 'getType' ) |
213
|
|
|
->will( $this->returnValue( 'mysql' ) ); |
214
|
|
|
|
215
|
|
|
$store = $this->getMockBuilder( '\SMW\SQLStore\SQLStore' ) |
216
|
|
|
->disableOriginalConstructor() |
217
|
|
|
->getMock(); |
218
|
|
|
|
219
|
|
|
$store->expects( $this->once() ) |
220
|
|
|
->method( 'getConnection' ) |
221
|
|
|
->will( $this->returnValue( $connection ) ); |
222
|
|
|
|
223
|
|
|
$instance = new SQLStoreFactory( $store ); |
224
|
|
|
|
225
|
|
|
$this->assertInstanceOf( |
226
|
|
|
'SMW\SQLStore\Installer', |
227
|
|
|
$instance->newInstaller() |
228
|
|
|
); |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
} |
232
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.