1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* File contains Test 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
|
|
|
* @version //autogentag// |
10
|
|
|
*/ |
11
|
|
|
namespace eZ\Publish\Core\Persistence\Cache\Tests; |
12
|
|
|
|
13
|
|
|
use eZ\Publish\Core\Base\Exceptions\NotFoundException; |
14
|
|
|
use eZ\Publish\SPI\Persistence\User; |
15
|
|
|
use eZ\Publish\SPI\Persistence\User\Role; |
16
|
|
|
use eZ\Publish\SPI\Persistence\User\RoleAssignment; |
17
|
|
|
use eZ\Publish\SPI\Persistence\User\RoleUpdateStruct; |
18
|
|
|
use eZ\Publish\SPI\Persistence\User\Policy; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Test case for Persistence\Cache\UserHandler. |
22
|
|
|
*/ |
23
|
|
|
class UserHandlerTest extends HandlerTest |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Commented lines represent cached functions covered by specific unit tests further down. |
27
|
|
|
* |
28
|
|
|
* @return array |
29
|
|
|
*/ |
30
|
|
|
public function providerForUnCachedMethods() |
31
|
|
|
{ |
32
|
|
|
return array( |
33
|
|
|
//array( 'create', array( new User ) ), |
34
|
|
|
array('load', array(14)), |
35
|
|
|
array('loadByLogin', array('admin')), |
36
|
|
|
array('loadByEmail', array('[email protected]')), |
37
|
|
|
//array( 'update', array( new User ) ), |
38
|
|
|
//array( 'delete', array( 14 ) ), |
39
|
|
|
//array( 'createRole', array( new Role ) ), |
40
|
|
|
//array( 'loadRole', array( 22 ) ), |
41
|
|
|
array('loadRoleByIdentifier', array('users')), |
42
|
|
|
array('loadRoles', array()), |
43
|
|
|
array('loadRoleAssignmentsByRoleId', array(22)), |
44
|
|
|
//array( 'loadRoleAssignmentsByGroupId', array( 44, true ) ), |
45
|
|
|
//array( 'updateRole', array( new RoleUpdateStruct ) ), |
46
|
|
|
//array( 'deleteRole', array( 22 ) ), |
47
|
|
|
//array( 'addPolicy', array( 22, new Policy ) ), |
48
|
|
|
//array( 'updatePolicy', array( new Policy ) ), |
49
|
|
|
//array( 'deletePolicy', array( 22, 66 ) ), |
50
|
|
|
array('loadPoliciesByUserId', array(14)), |
51
|
|
|
//array( 'assignRole', array( 44, 22, array( 42 ) ) ), |
52
|
|
|
//array( 'unassignRole', array( 44, 22 ) ), |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @dataProvider providerForUnCachedMethods |
58
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler |
59
|
|
|
*/ |
60
|
|
View Code Duplication |
public function testUnCachedMethods($method, array $arguments) |
61
|
|
|
{ |
62
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
63
|
|
|
$this->cacheMock |
64
|
|
|
->expects($this->never()) |
65
|
|
|
->method($this->anything()); |
66
|
|
|
|
67
|
|
|
$innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
68
|
|
|
$this->persistenceHandlerMock |
69
|
|
|
->expects($this->once()) |
70
|
|
|
->method('userHandler') |
71
|
|
|
->will($this->returnValue($innerHandler)); |
72
|
|
|
|
73
|
|
|
$expects = $innerHandler |
74
|
|
|
->expects($this->once()) |
75
|
|
|
->method($method); |
76
|
|
|
|
77
|
|
|
if (isset($arguments[2])) { |
78
|
|
|
$expects->with($arguments[0], $arguments[1], $arguments[2]); |
79
|
|
|
} elseif (isset($arguments[1])) { |
80
|
|
|
$expects->with($arguments[0], $arguments[1]); |
81
|
|
|
} elseif (isset($arguments[0])) { |
82
|
|
|
$expects->with($arguments[0]); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
$expects->will($this->returnValue(null)); |
86
|
|
|
|
87
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
88
|
|
|
call_user_func_array(array($handler, $method), $arguments); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::create |
93
|
|
|
*/ |
94
|
|
View Code Duplication |
public function testCreate() |
95
|
|
|
{ |
96
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
97
|
|
|
|
98
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
99
|
|
|
$this->persistenceHandlerMock |
100
|
|
|
->expects($this->once()) |
101
|
|
|
->method('userHandler') |
102
|
|
|
->will($this->returnValue($innerHandlerMock)); |
103
|
|
|
|
104
|
|
|
$innerHandlerMock |
105
|
|
|
->expects($this->once()) |
106
|
|
|
->method('create') |
107
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User')) |
108
|
|
|
->will( |
109
|
|
|
$this->returnValue(true) |
110
|
|
|
); |
111
|
|
|
|
112
|
|
|
$this->cacheMock |
113
|
|
|
->expects($this->at(0)) |
114
|
|
|
->method('clear') |
115
|
|
|
->with('content', 42) |
116
|
|
|
->will($this->returnValue(true)); |
117
|
|
|
|
118
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
119
|
|
|
$handler->create(new User(array('id' => 42))); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::update |
124
|
|
|
*/ |
125
|
|
View Code Duplication |
public function testUpdate() |
126
|
|
|
{ |
127
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
128
|
|
|
|
129
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
130
|
|
|
$this->persistenceHandlerMock |
131
|
|
|
->expects($this->once()) |
132
|
|
|
->method('userHandler') |
133
|
|
|
->will($this->returnValue($innerHandlerMock)); |
134
|
|
|
|
135
|
|
|
$innerHandlerMock |
136
|
|
|
->expects($this->once()) |
137
|
|
|
->method('update') |
138
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User')) |
139
|
|
|
->will( |
140
|
|
|
$this->returnValue(true) |
141
|
|
|
); |
142
|
|
|
|
143
|
|
|
$this->cacheMock |
144
|
|
|
->expects($this->at(0)) |
145
|
|
|
->method('clear') |
146
|
|
|
->with('content', 42) |
147
|
|
|
->will($this->returnValue(true)); |
148
|
|
|
|
149
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
150
|
|
|
$handler->update(new User(array('id' => 42))); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::delete |
155
|
|
|
*/ |
156
|
|
View Code Duplication |
public function testDelete() |
157
|
|
|
{ |
158
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
159
|
|
|
|
160
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
161
|
|
|
$this->persistenceHandlerMock |
162
|
|
|
->expects($this->once()) |
163
|
|
|
->method('userHandler') |
164
|
|
|
->will($this->returnValue($innerHandlerMock)); |
165
|
|
|
|
166
|
|
|
$innerHandlerMock |
167
|
|
|
->expects($this->once()) |
168
|
|
|
->method('delete') |
169
|
|
|
->with(14) |
170
|
|
|
->will( |
171
|
|
|
$this->returnValue(true) |
172
|
|
|
); |
173
|
|
|
|
174
|
|
|
$this->cacheMock |
175
|
|
|
->expects($this->at(0)) |
176
|
|
|
->method('clear') |
177
|
|
|
->with('content', 14) |
178
|
|
|
->will($this->returnValue(true)); |
179
|
|
|
|
180
|
|
|
$this->cacheMock |
181
|
|
|
->expects($this->at(1)) |
182
|
|
|
->method('clear') |
183
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 14) |
184
|
|
|
->will($this->returnValue(true)); |
185
|
|
|
|
186
|
|
|
$this->cacheMock |
187
|
|
|
->expects($this->at(2)) |
188
|
|
|
->method('clear') |
189
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 'inherited', 14) |
190
|
|
|
->will($this->returnValue(true)); |
191
|
|
|
|
192
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
193
|
|
|
$handler->delete(14); |
194
|
|
|
} |
195
|
|
|
|
196
|
|
|
/** |
197
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRole |
198
|
|
|
*/ |
199
|
|
View Code Duplication |
public function testLoadRoleIsMiss() |
200
|
|
|
{ |
201
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
202
|
|
|
|
203
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
204
|
|
|
$this->cacheMock |
205
|
|
|
->expects($this->once()) |
206
|
|
|
->method('getItem') |
207
|
|
|
->with('user', 'role', 33) |
208
|
|
|
->will($this->returnValue($cacheItemMock)); |
209
|
|
|
|
210
|
|
|
$cacheItemMock |
211
|
|
|
->expects($this->once()) |
212
|
|
|
->method('get') |
213
|
|
|
->will($this->returnValue(null)); |
214
|
|
|
|
215
|
|
|
$cacheItemMock |
216
|
|
|
->expects($this->once()) |
217
|
|
|
->method('isMiss') |
218
|
|
|
->will($this->returnValue(true)); |
219
|
|
|
|
220
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
221
|
|
|
$this->persistenceHandlerMock |
222
|
|
|
->expects($this->once()) |
223
|
|
|
->method('userHandler') |
224
|
|
|
->will($this->returnValue($innerHandlerMock)); |
225
|
|
|
|
226
|
|
|
$innerHandlerMock |
227
|
|
|
->expects($this->once()) |
228
|
|
|
->method('loadRole') |
229
|
|
|
->with(33) |
230
|
|
|
->will( |
231
|
|
|
$this->returnValue(new Role()) |
232
|
|
|
); |
233
|
|
|
|
234
|
|
|
$cacheItemMock |
235
|
|
|
->expects($this->once()) |
236
|
|
|
->method('set') |
237
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\Role')); |
238
|
|
|
|
239
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
240
|
|
|
$handler->loadRole(33); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
/** |
244
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRole |
245
|
|
|
*/ |
246
|
|
View Code Duplication |
public function testLoadRoleHasCache() |
247
|
|
|
{ |
248
|
|
|
$this->loggerMock->expects($this->never())->method('logCall'); |
249
|
|
|
|
250
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
251
|
|
|
$this->cacheMock |
252
|
|
|
->expects($this->once()) |
253
|
|
|
->method('getItem') |
254
|
|
|
->with('user', 'role', 33) |
255
|
|
|
->will($this->returnValue($cacheItemMock)); |
256
|
|
|
|
257
|
|
|
$cacheItemMock |
258
|
|
|
->expects($this->once()) |
259
|
|
|
->method('get') |
260
|
|
|
->will($this->returnValue(new Role())); |
261
|
|
|
|
262
|
|
|
$cacheItemMock |
263
|
|
|
->expects($this->once()) |
264
|
|
|
->method('isMiss') |
265
|
|
|
->will($this->returnValue(false)); |
266
|
|
|
|
267
|
|
|
$this->persistenceHandlerMock |
268
|
|
|
->expects($this->never()) |
269
|
|
|
->method($this->anything()); |
270
|
|
|
|
271
|
|
|
$cacheItemMock |
272
|
|
|
->expects($this->never()) |
273
|
|
|
->method('set'); |
274
|
|
|
|
275
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
276
|
|
|
$handler->loadRole(33); |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
/** |
280
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId |
281
|
|
|
*/ |
282
|
|
View Code Duplication |
public function testLoadRoleAssignmentsByGroupIdIsMiss() |
283
|
|
|
{ |
284
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
285
|
|
|
|
286
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
287
|
|
|
$this->cacheMock |
288
|
|
|
->expects($this->once()) |
289
|
|
|
->method('getItem') |
290
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 42) |
291
|
|
|
->will($this->returnValue($cacheItemMock)); |
292
|
|
|
|
293
|
|
|
$cacheItemMock |
294
|
|
|
->expects($this->once()) |
295
|
|
|
->method('get') |
296
|
|
|
->will($this->returnValue(null)); |
297
|
|
|
|
298
|
|
|
$cacheItemMock |
299
|
|
|
->expects($this->once()) |
300
|
|
|
->method('isMiss') |
301
|
|
|
->will($this->returnValue(true)); |
302
|
|
|
|
303
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
304
|
|
|
$this->persistenceHandlerMock |
305
|
|
|
->expects($this->once()) |
306
|
|
|
->method('userHandler') |
307
|
|
|
->will($this->returnValue($innerHandlerMock)); |
308
|
|
|
|
309
|
|
|
$innerHandlerMock |
310
|
|
|
->expects($this->once()) |
311
|
|
|
->method('loadRoleAssignmentsByGroupId') |
312
|
|
|
->with(42, false) |
313
|
|
|
->will( |
314
|
|
|
$this->returnValue( |
315
|
|
|
array( |
316
|
|
|
new RoleAssignment(array('roleId' => 33)), |
317
|
|
|
) |
318
|
|
|
) |
319
|
|
|
); |
320
|
|
|
|
321
|
|
|
$cacheItemMock |
322
|
|
|
->expects($this->once()) |
323
|
|
|
->method('set') |
324
|
|
|
->with($this->isType('array')); |
325
|
|
|
|
326
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
327
|
|
|
$roleAssignments = $handler->loadRoleAssignmentsByGroupId(42); |
328
|
|
|
|
329
|
|
|
$this->assertEquals(1, count($roleAssignments)); |
330
|
|
|
$this->assertInstanceOf('\\eZ\\Publish\\SPI\\Persistence\\User\\RoleAssignment', $roleAssignments[0]); |
331
|
|
|
$this->assertEquals(33, $roleAssignments[0]->roleId); |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
/** |
335
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId |
336
|
|
|
*/ |
337
|
|
View Code Duplication |
public function testLoadRoleAssignmentsByGroupIdHasCache() |
338
|
|
|
{ |
339
|
|
|
$this->loggerMock->expects($this->never())->method('logCall'); |
340
|
|
|
|
341
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
342
|
|
|
$this->cacheMock |
343
|
|
|
->expects($this->once()) |
344
|
|
|
->method('getItem') |
345
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 42) |
346
|
|
|
->will($this->returnValue($cacheItemMock)); |
347
|
|
|
|
348
|
|
|
$cacheItemMock |
349
|
|
|
->expects($this->once()) |
350
|
|
|
->method('get') |
351
|
|
|
->will( |
352
|
|
|
$this->returnValue(array(new RoleAssignment(array('roleId' => 33)))) |
353
|
|
|
); |
354
|
|
|
|
355
|
|
|
$cacheItemMock |
356
|
|
|
->expects($this->once()) |
357
|
|
|
->method('isMiss') |
358
|
|
|
->will($this->returnValue(false)); |
359
|
|
|
|
360
|
|
|
$this->persistenceHandlerMock |
361
|
|
|
->expects($this->never()) |
362
|
|
|
->method($this->anything()); |
363
|
|
|
|
364
|
|
|
$cacheItemMock |
365
|
|
|
->expects($this->never()) |
366
|
|
|
->method('set'); |
367
|
|
|
|
368
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
369
|
|
|
$roleAssignments = $handler->loadRoleAssignmentsByGroupId(42); |
370
|
|
|
|
371
|
|
|
$this->assertEquals(1, count($roleAssignments)); |
372
|
|
|
$this->assertInstanceOf('\\eZ\\Publish\\SPI\\Persistence\\User\\RoleAssignment', $roleAssignments[0]); |
373
|
|
|
$this->assertEquals(33, $roleAssignments[0]->roleId); |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId |
378
|
|
|
*/ |
379
|
|
View Code Duplication |
public function testLoadRoleAssignmentsByGroupIdInheritedIsMiss() |
380
|
|
|
{ |
381
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
382
|
|
|
|
383
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
384
|
|
|
$this->cacheMock |
385
|
|
|
->expects($this->once()) |
386
|
|
|
->method('getItem') |
387
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 'inherited', '42') |
388
|
|
|
->will($this->returnValue($cacheItemMock)); |
389
|
|
|
|
390
|
|
|
$cacheItemMock |
391
|
|
|
->expects($this->once()) |
392
|
|
|
->method('get') |
393
|
|
|
->will($this->returnValue(null)); |
394
|
|
|
|
395
|
|
|
$cacheItemMock |
396
|
|
|
->expects($this->once()) |
397
|
|
|
->method('isMiss') |
398
|
|
|
->will($this->returnValue(true)); |
399
|
|
|
|
400
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
401
|
|
|
$this->persistenceHandlerMock |
402
|
|
|
->expects($this->once()) |
403
|
|
|
->method('userHandler') |
404
|
|
|
->will($this->returnValue($innerHandlerMock)); |
405
|
|
|
|
406
|
|
|
$innerHandlerMock |
407
|
|
|
->expects($this->once()) |
408
|
|
|
->method('loadRoleAssignmentsByGroupId') |
409
|
|
|
->with(42, true) |
410
|
|
|
->will( |
411
|
|
|
$this->returnValue(array(new RoleAssignment(array('roleId' => 33)))) |
412
|
|
|
); |
413
|
|
|
|
414
|
|
|
$cacheItemMock |
415
|
|
|
->expects($this->once()) |
416
|
|
|
->method('set') |
417
|
|
|
->with($this->isType('array')); |
418
|
|
|
|
419
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
420
|
|
|
$roleAssignments = $handler->loadRoleAssignmentsByGroupId(42, true); |
421
|
|
|
|
422
|
|
|
$this->assertEquals(1, count($roleAssignments)); |
423
|
|
|
$this->assertInstanceOf('\\eZ\\Publish\\SPI\\Persistence\\User\\RoleAssignment', $roleAssignments[0]); |
424
|
|
|
$this->assertEquals(33, $roleAssignments[0]->roleId); |
425
|
|
|
} |
426
|
|
|
|
427
|
|
|
/** |
428
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::loadRoleAssignmentsByGroupId |
429
|
|
|
*/ |
430
|
|
View Code Duplication |
public function testLoadRoleAssignmentsByGroupIdInheritedHasCache() |
431
|
|
|
{ |
432
|
|
|
$this->loggerMock->expects($this->never())->method('logCall'); |
433
|
|
|
|
434
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
435
|
|
|
$this->cacheMock |
436
|
|
|
->expects($this->once()) |
437
|
|
|
->method('getItem') |
438
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 'inherited', '42') |
439
|
|
|
->will($this->returnValue($cacheItemMock)); |
440
|
|
|
|
441
|
|
|
$cacheItemMock |
442
|
|
|
->expects($this->once()) |
443
|
|
|
->method('get') |
444
|
|
|
->will( |
445
|
|
|
$this->returnValue(array(new RoleAssignment(array('roleId' => 33)))) |
446
|
|
|
); |
447
|
|
|
|
448
|
|
|
$cacheItemMock |
449
|
|
|
->expects($this->once()) |
450
|
|
|
->method('isMiss') |
451
|
|
|
->will($this->returnValue(false)); |
452
|
|
|
|
453
|
|
|
$this->persistenceHandlerMock |
454
|
|
|
->expects($this->never()) |
455
|
|
|
->method($this->anything()); |
456
|
|
|
|
457
|
|
|
$cacheItemMock |
458
|
|
|
->expects($this->never()) |
459
|
|
|
->method('set'); |
460
|
|
|
|
461
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
462
|
|
|
$roleAssignments = $handler->loadRoleAssignmentsByGroupId(42, true); |
463
|
|
|
|
464
|
|
|
$this->assertEquals(1, count($roleAssignments)); |
465
|
|
|
$this->assertInstanceOf('\\eZ\\Publish\\SPI\\Persistence\\User\\RoleAssignment', $roleAssignments[0]); |
466
|
|
|
$this->assertEquals(33, $roleAssignments[0]->roleId); |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
/** |
470
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::createRole |
471
|
|
|
*/ |
472
|
|
View Code Duplication |
public function testCreateRole() |
473
|
|
|
{ |
474
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
475
|
|
|
|
476
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
477
|
|
|
$this->persistenceHandlerMock |
478
|
|
|
->expects($this->once()) |
479
|
|
|
->method('userHandler') |
480
|
|
|
->will($this->returnValue($innerHandlerMock)); |
481
|
|
|
|
482
|
|
|
$innerHandlerMock |
483
|
|
|
->expects($this->once()) |
484
|
|
|
->method('createRole') |
485
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\RoleCreateStruct')) |
486
|
|
|
->will( |
487
|
|
|
$this->returnValue( |
488
|
|
|
new Role( |
489
|
|
|
['id' => 33, 'name' => 'Editors', 'identifier' => 'intranet', 'status' => Role::STATUS_DEFINED] |
490
|
|
|
) |
491
|
|
|
) |
492
|
|
|
); |
493
|
|
|
|
494
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
495
|
|
|
$this->cacheMock |
496
|
|
|
->expects($this->never()) |
497
|
|
|
->method('getItem'); |
498
|
|
|
|
499
|
|
|
$cacheItemMock |
500
|
|
|
->expects($this->never()) |
501
|
|
|
->method('set'); |
502
|
|
|
|
503
|
|
|
$cacheItemMock |
504
|
|
|
->expects($this->never()) |
505
|
|
|
->method('get'); |
506
|
|
|
|
507
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
508
|
|
|
$handler->createRole(new User\RoleCreateStruct()); |
509
|
|
|
} |
510
|
|
|
|
511
|
|
|
/** |
512
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::createRoleDraft |
513
|
|
|
*/ |
514
|
|
|
public function testCreateRoleDraft() |
515
|
|
|
{ |
516
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
517
|
|
|
|
518
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
519
|
|
|
$this->persistenceHandlerMock |
520
|
|
|
->expects($this->once()) |
521
|
|
|
->method('userHandler') |
522
|
|
|
->will($this->returnValue($innerHandlerMock)); |
523
|
|
|
|
524
|
|
|
$innerHandlerMock |
525
|
|
|
->expects($this->once()) |
526
|
|
|
->method('createRoleDraft') |
527
|
|
|
->with(33) |
528
|
|
|
->will( |
529
|
|
|
$this->returnValue( |
530
|
|
|
new Role( |
531
|
|
|
['id' => 33, 'name' => 'Editors', 'identifier' => 'intranet', 'status' => Role::STATUS_DRAFT] |
532
|
|
|
) |
533
|
|
|
) |
534
|
|
|
); |
535
|
|
|
|
536
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
537
|
|
|
$this->cacheMock |
538
|
|
|
->expects($this->never()) |
539
|
|
|
->method('getItem'); |
540
|
|
|
|
541
|
|
|
$cacheItemMock |
542
|
|
|
->expects($this->never()) |
543
|
|
|
->method('set'); |
544
|
|
|
|
545
|
|
|
$cacheItemMock |
546
|
|
|
->expects($this->never()) |
547
|
|
|
->method('get'); |
548
|
|
|
|
549
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
550
|
|
|
$role = new Role(['id' => 33]); |
551
|
|
|
$handler->createRoleDraft($role->id); |
552
|
|
|
} |
553
|
|
|
|
554
|
|
|
/** |
555
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::updateRole |
556
|
|
|
*/ |
557
|
|
View Code Duplication |
public function testUpdateRole() |
558
|
|
|
{ |
559
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
560
|
|
|
|
561
|
|
|
$innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
562
|
|
|
$this->persistenceHandlerMock |
563
|
|
|
->expects($this->once()) |
564
|
|
|
->method('userHandler') |
565
|
|
|
->will($this->returnValue($innerHandler)); |
566
|
|
|
|
567
|
|
|
$innerHandler |
568
|
|
|
->expects($this->once()) |
569
|
|
|
->method('updateRole') |
570
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\RoleUpdateStruct')); |
571
|
|
|
|
572
|
|
|
$roleUpdateStruct = new RoleUpdateStruct(); |
573
|
|
|
$roleUpdateStruct->id = 42; |
574
|
|
|
|
575
|
|
|
$this->cacheMock |
576
|
|
|
->expects($this->once()) |
577
|
|
|
->method('clear') |
578
|
|
|
->with('user', 'role', $roleUpdateStruct->id) |
579
|
|
|
->will($this->returnValue(true)); |
580
|
|
|
|
581
|
|
|
$this->cacheMock |
582
|
|
|
->expects($this->never()) |
583
|
|
|
->method('getItem'); |
584
|
|
|
|
585
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
586
|
|
|
$handler->updateRole($roleUpdateStruct); |
587
|
|
|
} |
588
|
|
|
|
589
|
|
|
/** |
590
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::updateRole |
591
|
|
|
*/ |
592
|
|
View Code Duplication |
public function testUpdateRoleDraft() |
593
|
|
|
{ |
594
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
595
|
|
|
|
596
|
|
|
$innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
597
|
|
|
$this->persistenceHandlerMock |
598
|
|
|
->expects($this->once()) |
599
|
|
|
->method('userHandler') |
600
|
|
|
->will($this->returnValue($innerHandler)); |
601
|
|
|
|
602
|
|
|
$innerHandler |
603
|
|
|
->expects($this->once()) |
604
|
|
|
->method('updateRole') |
605
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\RoleUpdateStruct')); |
606
|
|
|
|
607
|
|
|
$roleUpdateStruct = new RoleUpdateStruct(); |
608
|
|
|
$roleUpdateStruct->id = 42; |
609
|
|
|
|
610
|
|
|
$this->cacheMock |
611
|
|
|
->expects($this->once()) |
612
|
|
|
->method('clear') |
613
|
|
|
->with('user', 'role', $roleUpdateStruct->id) |
614
|
|
|
->will($this->returnValue(true)); |
615
|
|
|
|
616
|
|
|
$this->cacheMock |
617
|
|
|
->expects($this->never()) |
618
|
|
|
->method('getItem'); |
619
|
|
|
|
620
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
621
|
|
|
$handler->updateRole($roleUpdateStruct); |
622
|
|
|
} |
623
|
|
|
|
624
|
|
|
/** |
625
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::deleteRole |
626
|
|
|
*/ |
627
|
|
View Code Duplication |
public function testDeleteRole() |
628
|
|
|
{ |
629
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
630
|
|
|
|
631
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
632
|
|
|
$this->persistenceHandlerMock |
633
|
|
|
->expects($this->once()) |
634
|
|
|
->method('userHandler') |
635
|
|
|
->will($this->returnValue($innerHandlerMock)); |
636
|
|
|
|
637
|
|
|
$innerHandlerMock |
638
|
|
|
->expects($this->once()) |
639
|
|
|
->method('deleteRole') |
640
|
|
|
->with(33) |
641
|
|
|
->will( |
642
|
|
|
$this->returnValue(true) |
643
|
|
|
); |
644
|
|
|
|
645
|
|
|
$this->cacheMock |
646
|
|
|
->expects($this->at(0)) |
647
|
|
|
->method('clear') |
648
|
|
|
->with('user', 'role', 33) |
649
|
|
|
->will($this->returnValue(true)); |
650
|
|
|
|
651
|
|
|
$this->cacheMock |
652
|
|
|
->expects($this->at(1)) |
653
|
|
|
->method('clear') |
654
|
|
|
->with('user', 'role', 'assignments') |
655
|
|
|
->will($this->returnValue(true)); |
656
|
|
|
|
657
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
658
|
|
|
$handler->deleteRole(33); |
659
|
|
|
} |
660
|
|
|
|
661
|
|
|
/** |
662
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::deleteRole |
663
|
|
|
*/ |
664
|
|
|
public function testDeleteRoleDraft() |
665
|
|
|
{ |
666
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
667
|
|
|
|
668
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
669
|
|
|
$this->persistenceHandlerMock |
670
|
|
|
->expects($this->once()) |
671
|
|
|
->method('userHandler') |
672
|
|
|
->will($this->returnValue($innerHandlerMock)); |
673
|
|
|
|
674
|
|
|
$innerHandlerMock |
675
|
|
|
->expects($this->once()) |
676
|
|
|
->method('deleteRole') |
677
|
|
|
->with(33, Role::STATUS_DRAFT) |
678
|
|
|
->will( |
679
|
|
|
$this->returnValue(true) |
680
|
|
|
); |
681
|
|
|
|
682
|
|
|
$this->cacheMock |
683
|
|
|
->expects($this->never()) |
684
|
|
|
->method('clear'); |
685
|
|
|
|
686
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
687
|
|
|
$handler->deleteRole(33, Role::STATUS_DRAFT); |
688
|
|
|
} |
689
|
|
|
|
690
|
|
|
public function testPublishRoleDraftFromExistingRole() |
691
|
|
|
{ |
692
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
693
|
|
|
|
694
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
695
|
|
|
$this->persistenceHandlerMock |
696
|
|
|
->expects($this->once()) |
697
|
|
|
->method('userHandler') |
698
|
|
|
->willReturn($innerHandlerMock); |
699
|
|
|
|
700
|
|
|
$roleDraftId = 33; |
701
|
|
|
$originalRoleId = 30; |
702
|
|
|
$innerHandlerMock |
703
|
|
|
->expects($this->exactly(2)) |
704
|
|
|
->method('loadRole') |
705
|
|
|
->willReturnMap([ |
706
|
|
|
[$roleDraftId, Role::STATUS_DRAFT, new Role(['originalId' => $originalRoleId])], |
707
|
|
|
[$originalRoleId, Role::STATUS_DEFINED, new Role(['id' => $originalRoleId])], |
708
|
|
|
]); |
709
|
|
|
$innerHandlerMock |
710
|
|
|
->expects($this->once()) |
711
|
|
|
->method('publishRoleDraft') |
712
|
|
|
->with($roleDraftId); |
713
|
|
|
|
714
|
|
|
$this->cacheMock |
715
|
|
|
->expects($this->once()) |
716
|
|
|
->method('clear') |
717
|
|
|
->with('user', 'role', 'assignments') |
718
|
|
|
->will($this->returnValue(true)); |
719
|
|
|
|
720
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
721
|
|
|
$this->cacheMock |
722
|
|
|
->expects($this->once()) |
723
|
|
|
->method('getItem') |
724
|
|
|
->with('user', 'role', $originalRoleId) |
725
|
|
|
->will($this->returnValue($cacheItemMock)); |
726
|
|
|
|
727
|
|
|
$cacheItemMock |
728
|
|
|
->expects($this->once()) |
729
|
|
|
->method('set') |
730
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\Role')); |
731
|
|
|
|
732
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
733
|
|
|
$handler->publishRoleDraft($roleDraftId); |
734
|
|
|
} |
735
|
|
|
|
736
|
|
|
public function testPublishNewRoleDraft() |
737
|
|
|
{ |
738
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
739
|
|
|
|
740
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
741
|
|
|
$this->persistenceHandlerMock |
742
|
|
|
->expects($this->once()) |
743
|
|
|
->method('userHandler') |
744
|
|
|
->willReturn($innerHandlerMock); |
745
|
|
|
|
746
|
|
|
$roleDraftId = 33; |
747
|
|
|
$originalRoleId = -1; |
748
|
|
|
$innerHandlerMock |
749
|
|
|
->expects($this->at(0)) |
750
|
|
|
->method('loadRole') |
751
|
|
|
->with($roleDraftId, Role::STATUS_DRAFT) |
752
|
|
|
->willReturn(new Role(['originalId' => $originalRoleId])); |
753
|
|
|
$innerHandlerMock |
754
|
|
|
->expects($this->at(1)) |
755
|
|
|
->method('publishRoleDraft') |
756
|
|
|
->with($roleDraftId); |
757
|
|
|
$innerHandlerMock |
758
|
|
|
->expects($this->at(2)) |
759
|
|
|
->method('loadRole') |
760
|
|
|
->with($originalRoleId, Role::STATUS_DEFINED) |
761
|
|
|
->willThrowException(new NotFoundException('foo', 'bar')); |
762
|
|
|
$innerHandlerMock |
763
|
|
|
->expects($this->at(3)) |
764
|
|
|
->method('loadRole') |
765
|
|
|
->with($roleDraftId, Role::STATUS_DEFINED) |
766
|
|
|
->willReturn(new Role(['id' => $roleDraftId])); |
767
|
|
|
|
768
|
|
|
$this->cacheMock |
769
|
|
|
->expects($this->once()) |
770
|
|
|
->method('clear') |
771
|
|
|
->with('user', 'role', 'assignments') |
772
|
|
|
->will($this->returnValue(true)); |
773
|
|
|
|
774
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
775
|
|
|
$this->cacheMock |
776
|
|
|
->expects($this->once()) |
777
|
|
|
->method('getItem') |
778
|
|
|
->with('user', 'role', $roleDraftId) |
779
|
|
|
->will($this->returnValue($cacheItemMock)); |
780
|
|
|
|
781
|
|
|
$cacheItemMock |
782
|
|
|
->expects($this->once()) |
783
|
|
|
->method('set') |
784
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\Role')); |
785
|
|
|
|
786
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
787
|
|
|
$handler->publishRoleDraft($roleDraftId); |
788
|
|
|
} |
789
|
|
|
|
790
|
|
|
/** |
791
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::addPolicy |
792
|
|
|
*/ |
793
|
|
View Code Duplication |
public function testAddPolicy() |
794
|
|
|
{ |
795
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
796
|
|
|
|
797
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
798
|
|
|
$this->persistenceHandlerMock |
799
|
|
|
->expects($this->once()) |
800
|
|
|
->method('userHandler') |
801
|
|
|
->will($this->returnValue($innerHandlerMock)); |
802
|
|
|
|
803
|
|
|
$innerHandlerMock |
804
|
|
|
->expects($this->once()) |
805
|
|
|
->method('addPolicy') |
806
|
|
|
->with(33, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\Policy')) |
807
|
|
|
->will( |
808
|
|
|
$this->returnValue(new Policy()) |
809
|
|
|
); |
810
|
|
|
|
811
|
|
|
$this->cacheMock |
812
|
|
|
->expects($this->once()) |
813
|
|
|
->method('clear') |
814
|
|
|
->with('user', 'role', 33) |
815
|
|
|
->will($this->returnValue(true)); |
816
|
|
|
|
817
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
818
|
|
|
$handler->addPolicy(33, new Policy()); |
819
|
|
|
} |
820
|
|
|
|
821
|
|
|
/** |
822
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::addPolicyByRoleDraft |
823
|
|
|
*/ |
824
|
|
|
public function testAddPolicyByRoleDraft() |
825
|
|
|
{ |
826
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
827
|
|
|
|
828
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
829
|
|
|
$this->persistenceHandlerMock |
830
|
|
|
->expects($this->once()) |
831
|
|
|
->method('userHandler') |
832
|
|
|
->will($this->returnValue($innerHandlerMock)); |
833
|
|
|
|
834
|
|
|
$innerHandlerMock |
835
|
|
|
->expects($this->once()) |
836
|
|
|
->method('addPolicyByRoleDraft') |
837
|
|
|
->with(33, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\Policy')) |
838
|
|
|
->will( |
839
|
|
|
$this->returnValue(new Policy()) |
840
|
|
|
); |
841
|
|
|
|
842
|
|
|
$this->cacheMock |
843
|
|
|
->expects($this->never()) |
844
|
|
|
->method('clear'); |
845
|
|
|
|
846
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
847
|
|
|
$handler->addPolicyByRoleDraft(33, new Policy()); |
848
|
|
|
} |
849
|
|
|
|
850
|
|
|
/** |
851
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::updatePolicy |
852
|
|
|
*/ |
853
|
|
View Code Duplication |
public function testUpdatePolicy() |
854
|
|
|
{ |
855
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
856
|
|
|
|
857
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
858
|
|
|
$this->persistenceHandlerMock |
859
|
|
|
->expects($this->once()) |
860
|
|
|
->method('userHandler') |
861
|
|
|
->will($this->returnValue($innerHandlerMock)); |
862
|
|
|
|
863
|
|
|
$innerHandlerMock |
864
|
|
|
->expects($this->once()) |
865
|
|
|
->method('updatePolicy') |
866
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\Policy')) |
867
|
|
|
->will( |
868
|
|
|
$this->returnValue(new Policy(array('roleId' => 33))) |
869
|
|
|
); |
870
|
|
|
|
871
|
|
|
$this->cacheMock |
872
|
|
|
->expects($this->once()) |
873
|
|
|
->method('clear') |
874
|
|
|
->with('user', 'role', 33) |
875
|
|
|
->will($this->returnValue(true)); |
876
|
|
|
|
877
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
878
|
|
|
$handler->updatePolicy(new Policy(array('roleId' => 33))); |
879
|
|
|
} |
880
|
|
|
|
881
|
|
|
/** |
882
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::deletePolicy |
883
|
|
|
*/ |
884
|
|
|
public function testDeletePolicy() |
885
|
|
|
{ |
886
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
887
|
|
|
|
888
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
889
|
|
|
$this->persistenceHandlerMock |
890
|
|
|
->expects($this->once()) |
891
|
|
|
->method('userHandler') |
892
|
|
|
->will($this->returnValue($innerHandlerMock)); |
893
|
|
|
|
894
|
|
|
$innerHandlerMock |
895
|
|
|
->expects($this->once()) |
896
|
|
|
->method('deletePolicy') |
897
|
|
|
->with(55) |
898
|
|
|
->will( |
899
|
|
|
$this->returnValue(true) |
900
|
|
|
); |
901
|
|
|
|
902
|
|
|
$this->cacheMock |
903
|
|
|
->expects($this->once()) |
904
|
|
|
->method('clear') |
905
|
|
|
->with('user', 'role') |
906
|
|
|
->will($this->returnValue(true)); |
907
|
|
|
|
908
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
909
|
|
|
$handler->deletePolicy(55); |
910
|
|
|
} |
911
|
|
|
|
912
|
|
|
/** |
913
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::assignRole |
914
|
|
|
*/ |
915
|
|
View Code Duplication |
public function testAssignRole() |
916
|
|
|
{ |
917
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
918
|
|
|
|
919
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
920
|
|
|
$this->persistenceHandlerMock |
921
|
|
|
->expects($this->once()) |
922
|
|
|
->method('userHandler') |
923
|
|
|
->will($this->returnValue($innerHandlerMock)); |
924
|
|
|
|
925
|
|
|
$innerHandlerMock |
926
|
|
|
->expects($this->once()) |
927
|
|
|
->method('assignRole') |
928
|
|
|
->with(33, 22) |
929
|
|
|
->will( |
930
|
|
|
$this->returnValue(true) |
931
|
|
|
); |
932
|
|
|
|
933
|
|
|
$this->cacheMock |
934
|
|
|
->expects($this->at(0)) |
935
|
|
|
->method('clear') |
936
|
|
|
->with('user', 'role', 22) |
937
|
|
|
->will($this->returnValue(true)); |
938
|
|
|
|
939
|
|
|
$this->cacheMock |
940
|
|
|
->expects($this->at(1)) |
941
|
|
|
->method('clear') |
942
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 33) |
943
|
|
|
->will($this->returnValue(true)); |
944
|
|
|
|
945
|
|
|
$this->cacheMock |
946
|
|
|
->expects($this->at(2)) |
947
|
|
|
->method('clear') |
948
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 'inherited') |
949
|
|
|
->will($this->returnValue(true)); |
950
|
|
|
|
951
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
952
|
|
|
$handler->assignRole(33, 22); |
953
|
|
|
} |
954
|
|
|
|
955
|
|
|
/** |
956
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\UserHandler::unassignRole |
957
|
|
|
*/ |
958
|
|
View Code Duplication |
public function testUnassignRole() |
959
|
|
|
{ |
960
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
961
|
|
|
|
962
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
963
|
|
|
$this->persistenceHandlerMock |
964
|
|
|
->expects($this->once()) |
965
|
|
|
->method('userHandler') |
966
|
|
|
->will($this->returnValue($innerHandlerMock)); |
967
|
|
|
|
968
|
|
|
$innerHandlerMock |
969
|
|
|
->expects($this->once()) |
970
|
|
|
->method('unassignRole') |
971
|
|
|
->with(33, 22) |
972
|
|
|
->will( |
973
|
|
|
$this->returnValue(true) |
974
|
|
|
); |
975
|
|
|
|
976
|
|
|
$this->cacheMock |
977
|
|
|
->expects($this->at(0)) |
978
|
|
|
->method('clear') |
979
|
|
|
->with('user', 'role', 22) |
980
|
|
|
->will($this->returnValue(true)); |
981
|
|
|
|
982
|
|
|
$this->cacheMock |
983
|
|
|
->expects($this->at(1)) |
984
|
|
|
->method('clear') |
985
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 33) |
986
|
|
|
->will($this->returnValue(true)); |
987
|
|
|
|
988
|
|
|
$this->cacheMock |
989
|
|
|
->expects($this->at(2)) |
990
|
|
|
->method('clear') |
991
|
|
|
->with('user', 'role', 'assignments', 'byGroup', 'inherited') |
992
|
|
|
->will($this->returnValue(true)); |
993
|
|
|
|
994
|
|
|
$handler = $this->persistenceCacheHandler->userHandler(); |
995
|
|
|
$handler->unassignRole(33, 22); |
996
|
|
|
} |
997
|
|
|
} |
998
|
|
|
|