1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File containing the RepositoryTest class. |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (C) eZ Systems AS. All rights reserved. |
7
|
|
|
* @license For full copyright and license information view LICENSE file distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
namespace eZ\Publish\API\Repository\Tests; |
10
|
|
|
|
11
|
|
|
use Exception; |
12
|
|
|
use eZ\Publish\API\Repository\NotificationService; |
13
|
|
|
use eZ\Publish\API\Repository\Repository; |
14
|
|
|
use eZ\Publish\Core\Repository\Values\User\UserReference; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Test case for operations in the Repository using in memory storage. |
18
|
|
|
* |
19
|
|
|
* @see eZ\Publish\API\Repository\Repository |
20
|
|
|
* @group integration |
21
|
|
|
*/ |
22
|
|
|
class RepositoryTest extends BaseTest |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* Test for the getRepository() method. |
26
|
|
|
*/ |
27
|
|
|
public function testGetRepository() |
28
|
|
|
{ |
29
|
|
|
$this->assertInstanceOf(Repository::class, $this->getSetupFactory()->getRepository(true)); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Test for the getContentService() method. |
34
|
|
|
* |
35
|
|
|
* @group content |
36
|
|
|
* @group user |
37
|
|
|
* |
38
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getContentService() |
39
|
|
|
*/ |
40
|
|
|
public function testGetContentService() |
41
|
|
|
{ |
42
|
|
|
$repository = $this->getRepository(); |
43
|
|
|
$this->assertInstanceOf( |
44
|
|
|
'\\eZ\\Publish\\API\\Repository\\ContentService', |
45
|
|
|
$repository->getContentService() |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Test for the getContentLanguageService() method. |
51
|
|
|
* |
52
|
|
|
* @group language |
53
|
|
|
* |
54
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getContentLanguageService() |
55
|
|
|
*/ |
56
|
|
|
public function testGetContentLanguageService() |
57
|
|
|
{ |
58
|
|
|
$repository = $this->getRepository(); |
59
|
|
|
$this->assertInstanceOf( |
60
|
|
|
'\\eZ\\Publish\\API\\Repository\\LanguageService', |
61
|
|
|
$repository->getContentLanguageService() |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Test for the getContentTypeService() method. |
67
|
|
|
* |
68
|
|
|
* @group content-type |
69
|
|
|
* @group field-type |
70
|
|
|
* @group user |
71
|
|
|
* |
72
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getContentTypeService() |
73
|
|
|
*/ |
74
|
|
|
public function testGetContentTypeService() |
75
|
|
|
{ |
76
|
|
|
$repository = $this->getRepository(); |
77
|
|
|
$this->assertInstanceOf( |
78
|
|
|
'\\eZ\\Publish\\API\\Repository\\ContentTypeService', |
79
|
|
|
$repository->getContentTypeService() |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Test for the getLocationService() method. |
85
|
|
|
* |
86
|
|
|
* @group location |
87
|
|
|
* |
88
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getLocationService() |
89
|
|
|
*/ |
90
|
|
|
public function testGetLocationService() |
91
|
|
|
{ |
92
|
|
|
$repository = $this->getRepository(); |
93
|
|
|
$this->assertInstanceOf( |
94
|
|
|
'\\eZ\\Publish\\API\\Repository\\LocationService', |
95
|
|
|
$repository->getLocationService() |
96
|
|
|
); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* Test for the getSectionService() method. |
101
|
|
|
* |
102
|
|
|
* @group section |
103
|
|
|
* |
104
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getSectionService() |
105
|
|
|
*/ |
106
|
|
|
public function testGetSectionService() |
107
|
|
|
{ |
108
|
|
|
$repository = $this->getRepository(); |
109
|
|
|
$this->assertInstanceOf( |
110
|
|
|
'\\eZ\\Publish\\API\\Repository\\SectionService', |
111
|
|
|
$repository->getSectionService() |
112
|
|
|
); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Test for the getUserService() method. |
117
|
|
|
* |
118
|
|
|
* @group user |
119
|
|
|
* |
120
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getUserService() |
121
|
|
|
*/ |
122
|
|
|
public function testGetUserService() |
123
|
|
|
{ |
124
|
|
|
$repository = $this->getRepository(); |
125
|
|
|
$this->assertInstanceOf( |
126
|
|
|
'\\eZ\\Publish\\API\\Repository\\UserService', |
127
|
|
|
$repository->getUserService() |
128
|
|
|
); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Test for the getNotificationService() method. |
133
|
|
|
* |
134
|
|
|
* @group user |
135
|
|
|
* |
136
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getNotificationService() |
137
|
|
|
*/ |
138
|
|
|
public function testGetNotificationService() |
139
|
|
|
{ |
140
|
|
|
$repository = $this->getRepository(); |
141
|
|
|
$this->assertInstanceOf( |
142
|
|
|
NotificationService::class, |
143
|
|
|
$repository->getNotificationService() |
144
|
|
|
); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Test for the getTrashService() method. |
149
|
|
|
* |
150
|
|
|
* @group trash |
151
|
|
|
* |
152
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getTrashService() |
153
|
|
|
*/ |
154
|
|
|
public function testGetTrashService() |
155
|
|
|
{ |
156
|
|
|
$repository = $this->getRepository(); |
157
|
|
|
$this->assertInstanceOf( |
158
|
|
|
'\\eZ\\Publish\\API\\Repository\\TrashService', |
159
|
|
|
$repository->getTrashService() |
160
|
|
|
); |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Test for the getRoleService() method. |
165
|
|
|
* |
166
|
|
|
* @group role |
167
|
|
|
* |
168
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getRoleService() |
169
|
|
|
*/ |
170
|
|
|
public function testGetRoleService() |
171
|
|
|
{ |
172
|
|
|
$repository = $this->getRepository(); |
173
|
|
|
$this->assertInstanceOf( |
174
|
|
|
'\\eZ\\Publish\\API\\Repository\\RoleService', |
175
|
|
|
$repository->getRoleService() |
176
|
|
|
); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Test for the getURLAliasService() method. |
181
|
|
|
* |
182
|
|
|
* @group url-alias |
183
|
|
|
* |
184
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getURLAliasService() |
185
|
|
|
*/ |
186
|
|
|
public function testGetURLAliasService() |
187
|
|
|
{ |
188
|
|
|
$repository = $this->getRepository(); |
189
|
|
|
$this->assertInstanceOf( |
190
|
|
|
'\\eZ\\Publish\\API\\Repository\\URLAliasService', |
191
|
|
|
$repository->getURLAliasService() |
192
|
|
|
); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Test for the getUrlWildcardService() method. |
197
|
|
|
* |
198
|
|
|
* @group url-wildcard |
199
|
|
|
* |
200
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getUrlWildcardService() |
201
|
|
|
*/ |
202
|
|
|
public function testGetURLWildcardService() |
203
|
|
|
{ |
204
|
|
|
$repository = $this->getRepository(); |
205
|
|
|
$this->assertInstanceOf( |
206
|
|
|
'\\eZ\\Publish\\API\\Repository\\URLWildcardService', |
207
|
|
|
$repository->getURLWildcardService() |
208
|
|
|
); |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
/** |
212
|
|
|
* Test for the getObjectStateService(). |
213
|
|
|
* |
214
|
|
|
* @group object-state |
215
|
|
|
* |
216
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getObjectStateService() |
217
|
|
|
*/ |
218
|
|
|
public function testGetObjectStateService() |
219
|
|
|
{ |
220
|
|
|
$repository = $this->getRepository(); |
221
|
|
|
$this->assertInstanceOf( |
222
|
|
|
'\\eZ\\Publish\\API\\Repository\\ObjectStateService', |
223
|
|
|
$repository->getObjectStateService() |
224
|
|
|
); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* Test for the getFieldTypeService(). |
229
|
|
|
* |
230
|
|
|
* @group object-state |
231
|
|
|
* |
232
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getFieldTypeService() |
233
|
|
|
*/ |
234
|
|
|
public function testGetFieldTypeService() |
235
|
|
|
{ |
236
|
|
|
$repository = $this->getRepository(); |
237
|
|
|
$this->assertInstanceOf( |
238
|
|
|
'\\eZ\\Publish\\API\\Repository\\FieldTypeService', |
239
|
|
|
$repository->getFieldTypeService() |
240
|
|
|
); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* Test for the getSearchService() method. |
245
|
|
|
* |
246
|
|
|
* @group search |
247
|
|
|
* |
248
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getSearchService() |
249
|
|
|
*/ |
250
|
|
|
public function testGetSearchService() |
251
|
|
|
{ |
252
|
|
|
$repository = $this->getRepository(); |
253
|
|
|
|
254
|
|
|
$this->assertInstanceOf( |
255
|
|
|
'\\eZ\\Publish\\API\\Repository\\SearchService', |
256
|
|
|
$repository->getSearchService() |
257
|
|
|
); |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* Test for the getSearchService() method. |
262
|
|
|
* |
263
|
|
|
* @group permission |
264
|
|
|
* |
265
|
|
|
* @see \eZ\Publish\API\Repository\Repository::getPermissionResolver() |
266
|
|
|
*/ |
267
|
|
|
public function testGetPermissionResolver() |
268
|
|
|
{ |
269
|
|
|
$repository = $this->getRepository(); |
270
|
|
|
|
271
|
|
|
$this->assertInstanceOf( |
272
|
|
|
'\\eZ\\Publish\\API\\Repository\\PermissionResolver', |
273
|
|
|
$repository->getPermissionResolver() |
274
|
|
|
); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* Test for the commit() method. |
279
|
|
|
* |
280
|
|
|
* @see \eZ\Publish\API\Repository\Repository::commit() |
281
|
|
|
*/ |
282
|
|
|
public function testCommit() |
283
|
|
|
{ |
284
|
|
|
$repository = $this->getRepository(); |
285
|
|
|
|
286
|
|
|
try { |
287
|
|
|
$repository->beginTransaction(); |
288
|
|
|
$repository->commit(); |
289
|
|
|
} catch (Exception $e) { |
290
|
|
|
// Cleanup hanging transaction on error |
291
|
|
|
$repository->rollback(); |
292
|
|
|
throw $e; |
293
|
|
|
} |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* Test for the commit() method. |
298
|
|
|
* |
299
|
|
|
* @see \eZ\Publish\API\Repository\Repository::commit() |
300
|
|
|
*/ |
301
|
|
|
public function testCommitThrowsRuntimeException() |
302
|
|
|
{ |
303
|
|
|
$this->expectException(\RuntimeException::class); |
304
|
|
|
|
305
|
|
|
$repository = $this->getRepository(); |
306
|
|
|
$repository->commit(); |
307
|
|
|
} |
308
|
|
|
|
309
|
|
|
/** |
310
|
|
|
* Test for the rollback() method. |
311
|
|
|
* |
312
|
|
|
* @see \eZ\Publish\API\Repository\Repository::rollback() |
313
|
|
|
*/ |
314
|
|
|
public function testRollback() |
315
|
|
|
{ |
316
|
|
|
$repository = $this->getRepository(); |
317
|
|
|
$repository->beginTransaction(); |
318
|
|
|
$repository->rollback(); |
319
|
|
|
} |
320
|
|
|
|
321
|
|
|
/** |
322
|
|
|
* Test for the rollback() method. |
323
|
|
|
* |
324
|
|
|
* @see \eZ\Publish\API\Repository\Repository::rollback() |
325
|
|
|
*/ |
326
|
|
|
public function testRollbackThrowsRuntimeException() |
327
|
|
|
{ |
328
|
|
|
$this->expectException(\RuntimeException::class); |
329
|
|
|
|
330
|
|
|
$repository = $this->getRepository(); |
331
|
|
|
$repository->rollback(); |
332
|
|
|
} |
333
|
|
|
} |
334
|
|
|
|