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