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\API\Repository\Values\Content\Relation as APIRelation; |
14
|
|
|
use eZ\Publish\SPI\Persistence\Content\Relation as SPIRelation; |
15
|
|
|
use eZ\Publish\Core\Persistence\Cache\ContentHandler; |
16
|
|
|
use eZ\Publish\SPI\Persistence\Content; |
17
|
|
|
use eZ\Publish\SPI\Persistence\Content\ContentInfo; |
18
|
|
|
use eZ\Publish\SPI\Persistence\Content\VersionInfo; |
19
|
|
|
use eZ\Publish\SPI\Persistence\Content\CreateStruct; |
20
|
|
|
use eZ\Publish\SPI\Persistence\Content\UpdateStruct; |
21
|
|
|
use eZ\Publish\SPI\Persistence\Content\MetadataUpdateStruct; |
22
|
|
|
use eZ\Publish\SPI\Persistence\Content\Relation\CreateStruct as RelationCreateStruct; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Test case for Persistence\Cache\ContentHandler. |
26
|
|
|
*/ |
27
|
|
|
class ContentHandlerTest extends HandlerTest |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @return array |
31
|
|
|
*/ |
32
|
|
|
public function providerForUnCachedMethods() |
33
|
|
|
{ |
34
|
|
|
return array( |
35
|
|
|
array('create', array(new CreateStruct())), |
36
|
|
|
array('createDraftFromVersion', array(2, 1, 14)), |
37
|
|
|
array('copy', array(2, 1)), |
38
|
|
|
//array( 'load', array( 2, 1, array( 'eng-GB' ) ) ), |
39
|
|
|
//array( 'load', array( 2, 1 ) ), |
40
|
|
|
//array( 'loadContentInfo', array( 2 ) ), |
41
|
|
|
array('loadVersionInfo', array(2, 1)), |
42
|
|
|
array('loadDraftsForUser', array(14)), |
43
|
|
|
//array( 'setStatus', array( 2, 0, 1 ) ), |
44
|
|
|
//array( 'updateMetadata', array( 2, new MetadataUpdateStruct ) ), |
45
|
|
|
//array( 'updateContent', array( 2, 1, new UpdateStruct ) ), |
46
|
|
|
//array( 'deleteContent', array( 2 ) ), |
47
|
|
|
//array( 'deleteVersion', array( 2, 1 ) ), |
48
|
|
|
array('listVersions', array(2)), |
49
|
|
|
array('addRelation', array(new RelationCreateStruct())), |
50
|
|
|
array('removeRelation', array(66, APIRelation::COMMON)), |
51
|
|
|
array('loadRelations', array(2, 1, 3)), |
52
|
|
|
array('loadReverseRelations', array(2, 3)), |
53
|
|
|
//array( 'publish', array( 2, 3, new MetadataUpdateStruct ) ), |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @dataProvider providerForUnCachedMethods |
59
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler |
60
|
|
|
*/ |
61
|
|
View Code Duplication |
public function testUnCachedMethods($method, array $arguments) |
62
|
|
|
{ |
63
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
64
|
|
|
$this->cacheMock |
65
|
|
|
->expects($this->never()) |
66
|
|
|
->method($this->anything()); |
67
|
|
|
|
68
|
|
|
$innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
69
|
|
|
$this->persistenceHandlerMock |
70
|
|
|
->expects($this->once()) |
71
|
|
|
->method('contentHandler') |
72
|
|
|
->will($this->returnValue($innerHandler)); |
73
|
|
|
|
74
|
|
|
$expects = $innerHandler |
75
|
|
|
->expects($this->once()) |
76
|
|
|
->method($method); |
77
|
|
|
|
78
|
|
|
if (isset($arguments[2])) { |
79
|
|
|
$expects->with($arguments[0], $arguments[1], $arguments[2]); |
80
|
|
|
} elseif (isset($arguments[1])) { |
81
|
|
|
$expects->with($arguments[0], $arguments[1]); |
82
|
|
|
} elseif (isset($arguments[0])) { |
83
|
|
|
$expects->with($arguments[0]); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$expects->will($this->returnValue(null)); |
87
|
|
|
|
88
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
89
|
|
|
call_user_func_array(array($handler, $method), $arguments); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::load |
94
|
|
|
*/ |
95
|
|
|
public function testLoadCacheIsMiss() |
96
|
|
|
{ |
97
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
98
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
99
|
|
|
$this->cacheMock |
100
|
|
|
->expects($this->once()) |
101
|
|
|
->method('getItem') |
102
|
|
|
->with('content', 2, 1, 'eng-GB|eng-US') |
103
|
|
|
->will($this->returnValue($cacheItemMock)); |
104
|
|
|
|
105
|
|
|
$cacheItemMock |
106
|
|
|
->expects($this->once()) |
107
|
|
|
->method('get') |
108
|
|
|
->will($this->returnValue(null)); |
109
|
|
|
|
110
|
|
|
$cacheItemMock |
111
|
|
|
->expects($this->once()) |
112
|
|
|
->method('isMiss') |
113
|
|
|
->will($this->returnValue(true)); |
114
|
|
|
|
115
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
116
|
|
|
$this->persistenceHandlerMock |
117
|
|
|
->expects($this->once()) |
118
|
|
|
->method('contentHandler') |
119
|
|
|
->will($this->returnValue($innerHandlerMock)); |
120
|
|
|
|
121
|
|
|
$innerHandlerMock |
122
|
|
|
->expects($this->once()) |
123
|
|
|
->method('load') |
124
|
|
|
->with(2, 1, array('eng-GB', 'eng-US')) |
125
|
|
|
->will( |
126
|
|
|
$this->returnValue( |
127
|
|
|
new Content( |
128
|
|
|
array( |
129
|
|
|
'fields' => array(), |
130
|
|
|
'versionInfo' => new VersionInfo( |
131
|
|
|
array( |
132
|
|
|
'versionNo' => 1, |
133
|
|
|
'contentInfo' => new ContentInfo(array('id' => 2)), |
134
|
|
|
) |
135
|
|
|
), |
136
|
|
|
) |
137
|
|
|
) |
138
|
|
|
) |
139
|
|
|
); |
140
|
|
|
|
141
|
|
|
$cacheItemMock |
142
|
|
|
->expects($this->once()) |
143
|
|
|
->method('set') |
144
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content')); |
145
|
|
|
|
146
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
147
|
|
|
$handler->load(2, 1, array('eng-GB', 'eng-US')); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::load |
152
|
|
|
*/ |
153
|
|
|
public function testLoadHasCache() |
154
|
|
|
{ |
155
|
|
|
$this->loggerMock->expects($this->never())->method($this->anything()); |
156
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
157
|
|
|
$this->cacheMock |
158
|
|
|
->expects($this->once()) |
159
|
|
|
->method('getItem') |
160
|
|
|
->with('content', 2, 1, ContentHandler::ALL_TRANSLATIONS_KEY) |
161
|
|
|
->will($this->returnValue($cacheItemMock)); |
162
|
|
|
|
163
|
|
|
$cacheItemMock |
164
|
|
|
->expects($this->once()) |
165
|
|
|
->method('isMiss') |
166
|
|
|
->will($this->returnValue(false)); |
167
|
|
|
|
168
|
|
|
$this->persistenceHandlerMock |
169
|
|
|
->expects($this->never()) |
170
|
|
|
->method('contentHandler'); |
171
|
|
|
|
172
|
|
|
$cacheItemMock |
173
|
|
|
->expects($this->once()) |
174
|
|
|
->method('get') |
175
|
|
|
->will( |
176
|
|
|
$this->returnValue( |
177
|
|
|
new Content( |
178
|
|
|
array( |
179
|
|
|
'fields' => array(), |
180
|
|
|
'versionInfo' => new VersionInfo( |
181
|
|
|
array( |
182
|
|
|
'versionNo' => 1, |
183
|
|
|
'contentInfo' => new ContentInfo(array('id' => 2)), |
184
|
|
|
) |
185
|
|
|
), |
186
|
|
|
) |
187
|
|
|
) |
188
|
|
|
) |
189
|
|
|
); |
190
|
|
|
|
191
|
|
|
$cacheItemMock |
192
|
|
|
->expects($this->never()) |
193
|
|
|
->method('set'); |
194
|
|
|
|
195
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
196
|
|
|
$handler->load(2, 1); |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::loadContentInfo |
201
|
|
|
*/ |
202
|
|
|
public function testLoadContentInfoCacheIsMiss() |
203
|
|
|
{ |
204
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
205
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
206
|
|
|
$this->cacheMock |
207
|
|
|
->expects($this->once()) |
208
|
|
|
->method('getItem') |
209
|
|
|
->with('content', 'info', 2) |
210
|
|
|
->will($this->returnValue($cacheItemMock)); |
211
|
|
|
|
212
|
|
|
$cacheItemMock |
213
|
|
|
->expects($this->once()) |
214
|
|
|
->method('get') |
215
|
|
|
->will($this->returnValue(null)); |
216
|
|
|
|
217
|
|
|
$cacheItemMock |
218
|
|
|
->expects($this->once()) |
219
|
|
|
->method('isMiss') |
220
|
|
|
->will($this->returnValue(true)); |
221
|
|
|
|
222
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
223
|
|
|
$this->persistenceHandlerMock |
224
|
|
|
->expects($this->once()) |
225
|
|
|
->method('contentHandler') |
226
|
|
|
->will($this->returnValue($innerHandlerMock)); |
227
|
|
|
|
228
|
|
|
$innerHandlerMock |
229
|
|
|
->expects($this->once()) |
230
|
|
|
->method('loadContentInfo') |
231
|
|
|
->with(2) |
232
|
|
|
->will( |
233
|
|
|
$this->returnValue( |
234
|
|
|
new ContentInfo(array('id' => 2)) |
235
|
|
|
) |
236
|
|
|
); |
237
|
|
|
|
238
|
|
|
$cacheItemMock |
239
|
|
|
->expects($this->once()) |
240
|
|
|
->method('set') |
241
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ContentInfo')); |
242
|
|
|
|
243
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
244
|
|
|
$handler->loadContentInfo(2, 1); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
/** |
248
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::loadContentInfo |
249
|
|
|
*/ |
250
|
|
|
public function testLoadContentInfoHasCache() |
251
|
|
|
{ |
252
|
|
|
$this->loggerMock->expects($this->never())->method($this->anything()); |
253
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
254
|
|
|
$this->cacheMock |
255
|
|
|
->expects($this->once()) |
256
|
|
|
->method('getItem') |
257
|
|
|
->with('content', 'info', 2) |
258
|
|
|
->will($this->returnValue($cacheItemMock)); |
259
|
|
|
|
260
|
|
|
$cacheItemMock |
261
|
|
|
->expects($this->once()) |
262
|
|
|
->method('isMiss') |
263
|
|
|
->will($this->returnValue(false)); |
264
|
|
|
|
265
|
|
|
$this->persistenceHandlerMock |
266
|
|
|
->expects($this->never()) |
267
|
|
|
->method('contentHandler'); |
268
|
|
|
|
269
|
|
|
$cacheItemMock |
270
|
|
|
->expects($this->once()) |
271
|
|
|
->method('get') |
272
|
|
|
->will( |
273
|
|
|
$this->returnValue( |
274
|
|
|
new ContentInfo(array('id' => 2)) |
275
|
|
|
) |
276
|
|
|
); |
277
|
|
|
|
278
|
|
|
$cacheItemMock |
279
|
|
|
->expects($this->never()) |
280
|
|
|
->method('set'); |
281
|
|
|
|
282
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
283
|
|
|
$handler->loadContentInfo(2); |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::setStatus |
288
|
|
|
*/ |
289
|
|
View Code Duplication |
public function testSetStatus() |
290
|
|
|
{ |
291
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
292
|
|
|
|
293
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
294
|
|
|
$this->persistenceHandlerMock |
295
|
|
|
->expects($this->once()) |
296
|
|
|
->method('contentHandler') |
297
|
|
|
->will($this->returnValue($innerHandlerMock)); |
298
|
|
|
|
299
|
|
|
$innerHandlerMock |
300
|
|
|
->expects($this->once()) |
301
|
|
|
->method('setStatus') |
302
|
|
|
->with(2, VersionInfo::STATUS_ARCHIVED, 1) |
303
|
|
|
->will($this->returnValue(true)); |
304
|
|
|
|
305
|
|
|
$this->cacheMock |
306
|
|
|
->expects($this->once()) |
307
|
|
|
->method('clear') |
308
|
|
|
->with('content', 2, 1) |
309
|
|
|
->will($this->returnValue(null)); |
310
|
|
|
|
311
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
312
|
|
|
$handler->setStatus(2, VersionInfo::STATUS_ARCHIVED, 1); |
313
|
|
|
} |
314
|
|
|
|
315
|
|
|
/** |
316
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::setStatus |
317
|
|
|
*/ |
318
|
|
|
public function testSetStatusPublished() |
319
|
|
|
{ |
320
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
321
|
|
|
|
322
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
323
|
|
|
$this->persistenceHandlerMock |
324
|
|
|
->expects($this->once()) |
325
|
|
|
->method('contentHandler') |
326
|
|
|
->will($this->returnValue($innerHandlerMock)); |
327
|
|
|
|
328
|
|
|
$innerHandlerMock |
329
|
|
|
->expects($this->once()) |
330
|
|
|
->method('setStatus') |
331
|
|
|
->with(2, VersionInfo::STATUS_PUBLISHED, 1) |
332
|
|
|
->will($this->returnValue(true)); |
333
|
|
|
|
334
|
|
|
$this->cacheMock |
335
|
|
|
->expects($this->at(0)) |
336
|
|
|
->method('clear') |
337
|
|
|
->with('content', 2, 1) |
338
|
|
|
->will($this->returnValue(null)); |
339
|
|
|
|
340
|
|
|
$this->cacheMock |
341
|
|
|
->expects($this->at(1)) |
342
|
|
|
->method('clear') |
343
|
|
|
->with('content', 'info', 2) |
344
|
|
|
->will($this->returnValue(null)); |
345
|
|
|
|
346
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
347
|
|
|
$handler->setStatus(2, VersionInfo::STATUS_PUBLISHED, 1); |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
/** |
351
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::updateMetadata |
352
|
|
|
*/ |
353
|
|
|
public function testUpdateMetadata() |
354
|
|
|
{ |
355
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
356
|
|
|
|
357
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
358
|
|
|
$this->persistenceHandlerMock |
359
|
|
|
->expects($this->once()) |
360
|
|
|
->method('contentHandler') |
361
|
|
|
->will($this->returnValue($innerHandlerMock)); |
362
|
|
|
|
363
|
|
|
$innerHandlerMock |
364
|
|
|
->expects($this->once()) |
365
|
|
|
->method('updateMetadata') |
366
|
|
|
->with(2, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\MetadataUpdateStruct')) |
367
|
|
|
->will($this->returnValue(new ContentInfo(array('id' => 2)))); |
368
|
|
|
|
369
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
370
|
|
|
$this->cacheMock |
371
|
|
|
->expects($this->once()) |
372
|
|
|
->method('getItem') |
373
|
|
|
->with('content', 'info', 2) |
374
|
|
|
->will($this->returnValue($cacheItemMock)); |
375
|
|
|
|
376
|
|
|
$cacheItemMock |
377
|
|
|
->expects($this->once()) |
378
|
|
|
->method('set') |
379
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ContentInfo')); |
380
|
|
|
|
381
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
382
|
|
|
$handler->updateMetadata(2, new MetadataUpdateStruct()); |
383
|
|
|
} |
384
|
|
|
|
385
|
|
|
/** |
386
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::updateContent |
387
|
|
|
*/ |
388
|
|
|
public function testUpdateContent() |
389
|
|
|
{ |
390
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
391
|
|
|
|
392
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
393
|
|
|
$this->persistenceHandlerMock |
394
|
|
|
->expects($this->once()) |
395
|
|
|
->method('contentHandler') |
396
|
|
|
->will($this->returnValue($innerHandlerMock)); |
397
|
|
|
|
398
|
|
|
$innerHandlerMock |
399
|
|
|
->expects($this->once()) |
400
|
|
|
->method('updateContent') |
401
|
|
|
->with(2, 1, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\UpdateStruct')) |
402
|
|
|
->will( |
403
|
|
|
$this->returnValue( |
404
|
|
|
new Content( |
405
|
|
|
array( |
406
|
|
|
'fields' => array(), |
407
|
|
|
'versionInfo' => new VersionInfo( |
408
|
|
|
array( |
409
|
|
|
'versionNo' => 1, |
410
|
|
|
'contentInfo' => new ContentInfo(array('id' => 2)), |
411
|
|
|
) |
412
|
|
|
), |
413
|
|
|
) |
414
|
|
|
) |
415
|
|
|
) |
416
|
|
|
); |
417
|
|
|
|
418
|
|
|
$this->cacheMock |
419
|
|
|
->expects($this->once()) |
420
|
|
|
->method('clear') |
421
|
|
|
->with('content', 2, 1) |
422
|
|
|
->will($this->returnValue(null)); |
423
|
|
|
|
424
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
425
|
|
|
$this->cacheMock |
426
|
|
|
->expects($this->once()) |
427
|
|
|
->method('getItem') |
428
|
|
|
->with('content', 2, 1, ContentHandler::ALL_TRANSLATIONS_KEY) |
429
|
|
|
->will($this->returnValue($cacheItemMock)); |
430
|
|
|
|
431
|
|
|
$cacheItemMock |
432
|
|
|
->expects($this->once()) |
433
|
|
|
->method('set') |
434
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content')); |
435
|
|
|
|
436
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
437
|
|
|
$handler->updateContent(2, 1, new UpdateStruct()); |
438
|
|
|
} |
439
|
|
|
|
440
|
|
|
/** |
441
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::deleteContent |
442
|
|
|
*/ |
443
|
|
|
public function testDeleteContent() |
444
|
|
|
{ |
445
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
446
|
|
|
|
447
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
448
|
|
|
$this->persistenceHandlerMock |
449
|
|
|
->expects($this->exactly(2)) |
450
|
|
|
->method('contentHandler') |
451
|
|
|
->will($this->returnValue($innerHandlerMock)); |
452
|
|
|
|
453
|
|
|
$innerHandlerMock |
454
|
|
|
->expects($this->once()) |
455
|
|
|
->method('loadReverseRelations') |
456
|
|
|
->with(2, APIRelation::FIELD) |
457
|
|
|
->will( |
458
|
|
|
$this->returnValue( |
459
|
|
|
array( |
460
|
|
|
new SPIRelation(array('sourceContentId' => 42)), |
461
|
|
|
) |
462
|
|
|
) |
463
|
|
|
); |
464
|
|
|
|
465
|
|
|
$innerHandlerMock |
466
|
|
|
->expects($this->once()) |
467
|
|
|
->method('deleteContent') |
468
|
|
|
->with(2) |
469
|
|
|
->will($this->returnValue(true)); |
470
|
|
|
|
471
|
|
|
$this->cacheMock |
472
|
|
|
->expects($this->at(0)) |
473
|
|
|
->method('clear') |
474
|
|
|
->with('content', 42) |
475
|
|
|
->will($this->returnValue(null)); |
476
|
|
|
|
477
|
|
|
$this->cacheMock |
478
|
|
|
->expects($this->at(1)) |
479
|
|
|
->method('clear') |
480
|
|
|
->with('content', 2) |
481
|
|
|
->will($this->returnValue(null)); |
482
|
|
|
|
483
|
|
|
$this->cacheMock |
484
|
|
|
->expects($this->at(2)) |
485
|
|
|
->method('clear') |
486
|
|
|
->with('content', 'info', 2) |
487
|
|
|
->will($this->returnValue(null)); |
488
|
|
|
|
489
|
|
|
$this->cacheMock |
490
|
|
|
->expects($this->at(3)) |
491
|
|
|
->method('clear') |
492
|
|
|
->with('content', 'info', 'remoteId') |
493
|
|
|
->will($this->returnValue(null)); |
494
|
|
|
|
495
|
|
|
$this->cacheMock |
496
|
|
|
->expects($this->at(4)) |
497
|
|
|
->method('clear') |
498
|
|
|
->with('location', 'subtree') |
499
|
|
|
->will($this->returnValue(null)); |
500
|
|
|
|
501
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
502
|
|
|
$handler->deleteContent(2); |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
/** |
506
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::deleteVersion |
507
|
|
|
*/ |
508
|
|
|
public function testDeleteVersion() |
509
|
|
|
{ |
510
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
511
|
|
|
|
512
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
513
|
|
|
$this->persistenceHandlerMock |
514
|
|
|
->expects($this->once()) |
515
|
|
|
->method('contentHandler') |
516
|
|
|
->will($this->returnValue($innerHandlerMock)); |
517
|
|
|
|
518
|
|
|
$innerHandlerMock |
519
|
|
|
->expects($this->once()) |
520
|
|
|
->method('deleteVersion') |
521
|
|
|
->with(2, 1) |
522
|
|
|
->will($this->returnValue(true)); |
523
|
|
|
|
524
|
|
|
$this->cacheMock |
525
|
|
|
->expects($this->at(0)) |
526
|
|
|
->method('clear') |
527
|
|
|
->with('content', 2, 1) |
528
|
|
|
->will($this->returnValue(null)); |
529
|
|
|
|
530
|
|
|
$this->cacheMock |
531
|
|
|
->expects($this->at(1)) |
532
|
|
|
->method('clear') |
533
|
|
|
->with('content', 'info', 2) |
534
|
|
|
->will($this->returnValue(null)); |
535
|
|
|
|
536
|
|
|
$this->cacheMock |
537
|
|
|
->expects($this->at(2)) |
538
|
|
|
->method('clear') |
539
|
|
|
->with('content', 'info', 'remoteId') |
540
|
|
|
->will($this->returnValue(null)); |
541
|
|
|
|
542
|
|
|
$this->cacheMock |
543
|
|
|
->expects($this->at(3)) |
544
|
|
|
->method('clear') |
545
|
|
|
->with('location', 'subtree') |
546
|
|
|
->will($this->returnValue(null)); |
547
|
|
|
|
548
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
549
|
|
|
$handler->deleteVersion(2, 1); |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
/** |
553
|
|
|
* @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::publish |
554
|
|
|
*/ |
555
|
|
|
public function testPublish() |
556
|
|
|
{ |
557
|
|
|
$this->loggerMock->expects($this->once())->method('logCall'); |
558
|
|
|
|
559
|
|
|
$innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler'); |
560
|
|
|
$this->persistenceHandlerMock |
561
|
|
|
->expects($this->once()) |
562
|
|
|
->method('contentHandler') |
563
|
|
|
->will($this->returnValue($innerHandlerMock)); |
564
|
|
|
|
565
|
|
|
$innerHandlerMock |
566
|
|
|
->expects($this->once()) |
567
|
|
|
->method('publish') |
568
|
|
|
->with(2, 1, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\MetadataUpdateStruct')) |
569
|
|
|
->will( |
570
|
|
|
$this->returnValue( |
571
|
|
|
new Content( |
572
|
|
|
array( |
573
|
|
|
'fields' => array(), |
574
|
|
|
'versionInfo' => new VersionInfo( |
575
|
|
|
array( |
576
|
|
|
'versionNo' => 1, |
577
|
|
|
'contentInfo' => new ContentInfo(array('id' => 2)), |
578
|
|
|
) |
579
|
|
|
), |
580
|
|
|
) |
581
|
|
|
) |
582
|
|
|
) |
583
|
|
|
); |
584
|
|
|
|
585
|
|
|
$this->cacheMock |
586
|
|
|
->expects($this->at(0)) |
587
|
|
|
->method('clear') |
588
|
|
|
->with('content', 2) |
589
|
|
|
->will($this->returnValue(true)); |
590
|
|
|
|
591
|
|
|
$this->cacheMock |
592
|
|
|
->expects($this->at(1)) |
593
|
|
|
->method('clear') |
594
|
|
|
->with('content', 'info', 'remoteId') |
595
|
|
|
->will($this->returnValue(true)); |
596
|
|
|
|
597
|
|
|
$this->cacheMock |
598
|
|
|
->expects($this->at(2)) |
599
|
|
|
->method('clear') |
600
|
|
|
->with('location', 'subtree') |
601
|
|
|
->will($this->returnValue(true)); |
602
|
|
|
|
603
|
|
|
$cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
604
|
|
|
$this->cacheMock |
605
|
|
|
->expects($this->at(3)) |
606
|
|
|
->method('getItem') |
607
|
|
|
->with('content', 2, 1, ContentHandler::ALL_TRANSLATIONS_KEY) |
608
|
|
|
->will($this->returnValue($cacheItemMock)); |
609
|
|
|
|
610
|
|
|
$cacheItemMock |
611
|
|
|
->expects($this->once()) |
612
|
|
|
->method('set') |
613
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content')); |
614
|
|
|
|
615
|
|
|
$cacheItemMock |
616
|
|
|
->expects($this->never()) |
617
|
|
|
->method('get'); |
618
|
|
|
|
619
|
|
|
$cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface'); |
620
|
|
|
$this->cacheMock |
621
|
|
|
->expects($this->at(4)) |
622
|
|
|
->method('getItem') |
623
|
|
|
->with('content', 'info', 2) |
624
|
|
|
->will($this->returnValue($cacheItemMock2)); |
625
|
|
|
|
626
|
|
|
$cacheItemMock2 |
627
|
|
|
->expects($this->once()) |
628
|
|
|
->method('set') |
629
|
|
|
->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ContentInfo')); |
630
|
|
|
|
631
|
|
|
$cacheItemMock2 |
632
|
|
|
->expects($this->never()) |
633
|
|
|
->method('get'); |
634
|
|
|
|
635
|
|
|
$handler = $this->persistenceCacheHandler->contentHandler(); |
636
|
|
|
$handler->publish(2, 1, new MetadataUpdateStruct()); |
637
|
|
|
} |
638
|
|
|
} |
639
|
|
|
|