Completed
Push — ezp-30882-thumbnail ( 274ed9...d4335b )
by
unknown
14:43
created

RepositoryTest::testGetObjectStateService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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