Completed
Push — master ( 0455f1...3050cd )
by André
102:45 queued 67:40
created

ContentHandlerTest   C

Complexity

Total Complexity 16

Size/Duplication

Total Lines 666
Duplicated Lines 8.26 %

Coupling/Cohesion

Components 1
Dependencies 12

Importance

Changes 0
Metric Value
dl 55
loc 666
rs 6.7492
c 0
b 0
f 0
wmc 16
lcom 1
cbo 12

13 Methods

Rating   Name   Duplication   Size   Complexity  
B providerForUnCachedMethods() 0 24 1
B testUnCachedMethods() 30 30 4
B testLoadHasCache() 0 45 1
B testLoadContentInfoHasCache() 0 35 1
B testSetStatus() 25 25 1
B testSetStatusPublished() 0 31 1
A testLoadCacheIsMiss() 0 60 1
A testLoadContentInfoCacheIsMiss() 0 50 1
B testUpdateMetadata() 0 37 1
A testUpdateContent() 0 57 1
B testDeleteContent() 0 79 1
B testDeleteVersion() 0 43 1
B testPublish() 0 95 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
            ->will($this->returnValue($cacheItemMock));
146
147
        $cacheItemMock
148
            ->expects($this->once())
149
            ->method('save')
150
            ->with();
151
152
        $handler = $this->persistenceCacheHandler->contentHandler();
153
        $handler->load(2, 1, array('eng-GB', 'eng-US'));
154
    }
155
156
    /**
157
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::load
158
     */
159
    public function testLoadHasCache()
160
    {
161
        $this->loggerMock->expects($this->never())->method($this->anything());
162
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
163
        $this->cacheMock
164
            ->expects($this->once())
165
            ->method('getItem')
166
            ->with('content', 2, 1, ContentHandler::ALL_TRANSLATIONS_KEY)
167
            ->will($this->returnValue($cacheItemMock));
168
169
        $cacheItemMock
170
            ->expects($this->once())
171
            ->method('isMiss')
172
            ->will($this->returnValue(false));
173
174
        $this->persistenceHandlerMock
175
            ->expects($this->never())
176
            ->method('contentHandler');
177
178
        $cacheItemMock
179
            ->expects($this->once())
180
            ->method('get')
181
            ->will(
182
                $this->returnValue(
183
                    new Content(
184
                        array(
185
                            'fields' => array(),
186
                            'versionInfo' => new VersionInfo(
187
                                array(
188
                                    'versionNo' => 1,
189
                                    'contentInfo' => new ContentInfo(array('id' => 2)),
190
                                )
191
                            ),
192
                        )
193
                    )
194
                )
195
            );
196
197
        $cacheItemMock
198
            ->expects($this->never())
199
            ->method('set');
200
201
        $handler = $this->persistenceCacheHandler->contentHandler();
202
        $handler->load(2, 1);
203
    }
204
205
    /**
206
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::loadContentInfo
207
     */
208
    public function testLoadContentInfoCacheIsMiss()
209
    {
210
        $this->loggerMock->expects($this->once())->method('logCall');
211
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
212
        $this->cacheMock
213
            ->expects($this->once())
214
            ->method('getItem')
215
            ->with('content', 'info', 2)
216
            ->will($this->returnValue($cacheItemMock));
217
218
        $cacheItemMock
219
            ->expects($this->once())
220
            ->method('get')
221
            ->will($this->returnValue(null));
222
223
        $cacheItemMock
224
            ->expects($this->once())
225
            ->method('isMiss')
226
            ->will($this->returnValue(true));
227
228
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler');
229
        $this->persistenceHandlerMock
230
            ->expects($this->once())
231
            ->method('contentHandler')
232
            ->will($this->returnValue($innerHandlerMock));
233
234
        $innerHandlerMock
235
            ->expects($this->once())
236
            ->method('loadContentInfo')
237
            ->with(2)
238
            ->will(
239
                $this->returnValue(
240
                    new ContentInfo(array('id' => 2))
241
                )
242
            );
243
244
        $cacheItemMock
245
            ->expects($this->once())
246
            ->method('set')
247
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ContentInfo'))
248
            ->will($this->returnValue($cacheItemMock));
249
250
        $cacheItemMock
251
            ->expects($this->once())
252
            ->method('save')
253
            ->with();
254
255
        $handler = $this->persistenceCacheHandler->contentHandler();
256
        $handler->loadContentInfo(2, 1);
257
    }
258
259
    /**
260
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::loadContentInfo
261
     */
262
    public function testLoadContentInfoHasCache()
263
    {
264
        $this->loggerMock->expects($this->never())->method($this->anything());
265
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
266
        $this->cacheMock
267
            ->expects($this->once())
268
            ->method('getItem')
269
            ->with('content', 'info', 2)
270
            ->will($this->returnValue($cacheItemMock));
271
272
        $cacheItemMock
273
            ->expects($this->once())
274
            ->method('isMiss')
275
            ->will($this->returnValue(false));
276
277
        $this->persistenceHandlerMock
278
            ->expects($this->never())
279
            ->method('contentHandler');
280
281
        $cacheItemMock
282
            ->expects($this->once())
283
            ->method('get')
284
            ->will(
285
                $this->returnValue(
286
                    new ContentInfo(array('id' => 2))
287
                )
288
            );
289
290
        $cacheItemMock
291
            ->expects($this->never())
292
            ->method('set');
293
294
        $handler = $this->persistenceCacheHandler->contentHandler();
295
        $handler->loadContentInfo(2);
296
    }
297
298
    /**
299
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::setStatus
300
     */
301 View Code Duplication
    public function testSetStatus()
302
    {
303
        $this->loggerMock->expects($this->once())->method('logCall');
304
305
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler');
306
        $this->persistenceHandlerMock
307
            ->expects($this->once())
308
            ->method('contentHandler')
309
            ->will($this->returnValue($innerHandlerMock));
310
311
        $innerHandlerMock
312
            ->expects($this->once())
313
            ->method('setStatus')
314
            ->with(2, VersionInfo::STATUS_ARCHIVED, 1)
315
            ->will($this->returnValue(true));
316
317
        $this->cacheMock
318
            ->expects($this->once())
319
            ->method('clear')
320
            ->with('content', 2, 1)
321
            ->will($this->returnValue(null));
322
323
        $handler = $this->persistenceCacheHandler->contentHandler();
324
        $handler->setStatus(2, VersionInfo::STATUS_ARCHIVED, 1);
325
    }
326
327
    /**
328
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::setStatus
329
     */
330
    public function testSetStatusPublished()
331
    {
332
        $this->loggerMock->expects($this->once())->method('logCall');
333
334
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler');
335
        $this->persistenceHandlerMock
336
            ->expects($this->once())
337
            ->method('contentHandler')
338
            ->will($this->returnValue($innerHandlerMock));
339
340
        $innerHandlerMock
341
            ->expects($this->once())
342
            ->method('setStatus')
343
            ->with(2, VersionInfo::STATUS_PUBLISHED, 1)
344
            ->will($this->returnValue(true));
345
346
        $this->cacheMock
347
            ->expects($this->at(0))
348
            ->method('clear')
349
            ->with('content', 2, 1)
350
            ->will($this->returnValue(null));
351
352
        $this->cacheMock
353
            ->expects($this->at(1))
354
            ->method('clear')
355
            ->with('content', 'info', 2)
356
            ->will($this->returnValue(null));
357
358
        $handler = $this->persistenceCacheHandler->contentHandler();
359
        $handler->setStatus(2, VersionInfo::STATUS_PUBLISHED, 1);
360
    }
361
362
    /**
363
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::updateMetadata
364
     */
365
    public function testUpdateMetadata()
366
    {
367
        $this->loggerMock->expects($this->once())->method('logCall');
368
369
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler');
370
        $this->persistenceHandlerMock
371
            ->expects($this->once())
372
            ->method('contentHandler')
373
            ->will($this->returnValue($innerHandlerMock));
374
375
        $innerHandlerMock
376
            ->expects($this->once())
377
            ->method('updateMetadata')
378
            ->with(2, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\MetadataUpdateStruct'))
379
            ->will($this->returnValue(new ContentInfo(array('id' => 2))));
380
381
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
382
        $this->cacheMock
383
            ->expects($this->once())
384
            ->method('getItem')
385
            ->with('content', 'info', 2)
386
            ->will($this->returnValue($cacheItemMock));
387
388
        $cacheItemMock
389
            ->expects($this->once())
390
            ->method('set')
391
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ContentInfo'))
392
            ->will($this->returnValue($cacheItemMock));
393
394
        $cacheItemMock
395
            ->expects($this->once())
396
            ->method('save')
397
            ->with();
398
399
        $handler = $this->persistenceCacheHandler->contentHandler();
400
        $handler->updateMetadata(2, new MetadataUpdateStruct());
401
    }
402
403
    /**
404
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::updateContent
405
     */
406
    public function testUpdateContent()
407
    {
408
        $this->loggerMock->expects($this->once())->method('logCall');
409
410
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler');
411
        $this->persistenceHandlerMock
412
            ->expects($this->once())
413
            ->method('contentHandler')
414
            ->will($this->returnValue($innerHandlerMock));
415
416
        $innerHandlerMock
417
            ->expects($this->once())
418
            ->method('updateContent')
419
            ->with(2, 1, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\UpdateStruct'))
420
            ->will(
421
                $this->returnValue(
422
                    new Content(
423
                        array(
424
                            'fields' => array(),
425
                            'versionInfo' => new VersionInfo(
426
                                array(
427
                                    'versionNo' => 1,
428
                                    'contentInfo' => new ContentInfo(array('id' => 2)),
429
                                )
430
                            ),
431
                        )
432
                    )
433
                )
434
            );
435
436
        $this->cacheMock
437
            ->expects($this->once())
438
            ->method('clear')
439
            ->with('content', 2, 1)
440
            ->will($this->returnValue(null));
441
442
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
443
        $this->cacheMock
444
            ->expects($this->once())
445
            ->method('getItem')
446
            ->with('content', 2, 1, ContentHandler::ALL_TRANSLATIONS_KEY)
447
            ->will($this->returnValue($cacheItemMock));
448
449
        $cacheItemMock
450
            ->expects($this->once())
451
            ->method('set')
452
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'))
453
            ->will($this->returnValue($cacheItemMock));
454
455
        $cacheItemMock
456
            ->expects($this->once())
457
            ->method('save')
458
            ->with();
459
460
        $handler = $this->persistenceCacheHandler->contentHandler();
461
        $handler->updateContent(2, 1, new UpdateStruct());
462
    }
463
464
    /**
465
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::deleteContent
466
     */
467
    public function testDeleteContent()
468
    {
469
        $this->loggerMock->expects($this->once())->method('logCall');
470
471
        $innerLocationHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler');
472
        $this->persistenceHandlerMock
473
            ->expects($this->exactly(1))
474
            ->method('locationHandler')
475
            ->will($this->returnValue($innerLocationHandlerMock));
476
477
        $innerLocationHandlerMock
478
            ->expects($this->once())
479
            ->method('loadLocationsByContent')
480
            ->with(2)
481
            ->willReturn([new Content\Location(array('id' => 58))]);
482
483
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler');
484
        $this->persistenceHandlerMock
485
            ->expects($this->exactly(2))
486
            ->method('contentHandler')
487
            ->will($this->returnValue($innerHandlerMock));
488
489
        $innerHandlerMock
490
            ->expects($this->once())
491
            ->method('loadReverseRelations')
492
            ->with(2, APIRelation::FIELD)
493
            ->will(
494
                $this->returnValue(
495
                    array(
496
                        new SPIRelation(array('sourceContentId' => 42)),
497
                    )
498
                )
499
            );
500
501
        $innerHandlerMock
502
            ->expects($this->once())
503
            ->method('deleteContent')
504
            ->with(2)
505
            ->will($this->returnValue(true));
506
507
        $this->cacheMock
508
            ->expects($this->at(0))
509
            ->method('clear')
510
            ->with('content', 42)
511
            ->will($this->returnValue(null));
512
513
        $this->cacheMock
514
            ->expects($this->at(1))
515
            ->method('clear')
516
            ->with('content', 2)
517
            ->will($this->returnValue(null));
518
519
        $this->cacheMock
520
            ->expects($this->at(2))
521
            ->method('clear')
522
            ->with('content', 'info', 2)
523
            ->will($this->returnValue(null));
524
525
        $this->cacheMock
526
            ->expects($this->at(3))
527
            ->method('clear')
528
            ->with('content', 'info', 'remoteId')
529
            ->will($this->returnValue(null));
530
531
        $this->cacheMock
532
            ->expects($this->at(4))
533
            ->method('clear')
534
            ->with('location', 'subtree')
535
            ->will($this->returnValue(null));
536
537
        $this->cacheMock
538
            ->expects($this->at(5))
539
            ->method('clear')
540
            ->with('location', 58)
541
            ->will($this->returnValue(null));
542
543
        $handler = $this->persistenceCacheHandler->contentHandler();
544
        $handler->deleteContent(2);
545
    }
546
547
    /**
548
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::deleteVersion
549
     */
550
    public function testDeleteVersion()
551
    {
552
        $this->loggerMock->expects($this->once())->method('logCall');
553
554
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler');
555
        $this->persistenceHandlerMock
556
            ->expects($this->once())
557
            ->method('contentHandler')
558
            ->will($this->returnValue($innerHandlerMock));
559
560
        $innerHandlerMock
561
            ->expects($this->once())
562
            ->method('deleteVersion')
563
            ->with(2, 1)
564
            ->will($this->returnValue(true));
565
566
        $this->cacheMock
567
            ->expects($this->at(0))
568
            ->method('clear')
569
            ->with('content', 2, 1)
570
            ->will($this->returnValue(null));
571
572
        $this->cacheMock
573
            ->expects($this->at(1))
574
            ->method('clear')
575
            ->with('content', 'info', 2)
576
            ->will($this->returnValue(null));
577
578
        $this->cacheMock
579
            ->expects($this->at(2))
580
            ->method('clear')
581
            ->with('content', 'info', 'remoteId')
582
            ->will($this->returnValue(null));
583
584
        $this->cacheMock
585
            ->expects($this->at(3))
586
            ->method('clear')
587
            ->with('location', 'subtree')
588
            ->will($this->returnValue(null));
589
590
        $handler = $this->persistenceCacheHandler->contentHandler();
591
        $handler->deleteVersion(2, 1);
592
    }
593
594
    /**
595
     * @covers eZ\Publish\Core\Persistence\Cache\ContentHandler::publish
596
     */
597
    public function testPublish()
598
    {
599
        $this->loggerMock->expects($this->once())->method('logCall');
600
601
        $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Handler');
602
        $this->persistenceHandlerMock
603
            ->expects($this->once())
604
            ->method('contentHandler')
605
            ->will($this->returnValue($innerHandlerMock));
606
607
        $innerHandlerMock
608
            ->expects($this->once())
609
            ->method('publish')
610
            ->with(2, 1, $this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\MetadataUpdateStruct'))
611
            ->will(
612
                $this->returnValue(
613
                    new Content(
614
                        array(
615
                            'fields' => array(),
616
                            'versionInfo' => new VersionInfo(
617
                                array(
618
                                    'versionNo' => 1,
619
                                    'contentInfo' => new ContentInfo(array('id' => 2)),
620
                                )
621
                            ),
622
                        )
623
                    )
624
                )
625
            );
626
627
        $this->cacheMock
628
            ->expects($this->at(0))
629
            ->method('clear')
630
            ->with('content', 2)
631
            ->will($this->returnValue(true));
632
633
        $this->cacheMock
634
            ->expects($this->at(1))
635
            ->method('clear')
636
            ->with('content', 'info', 'remoteId')
637
            ->will($this->returnValue(true));
638
639
        $this->cacheMock
640
            ->expects($this->at(2))
641
            ->method('clear')
642
            ->with('location', 'subtree')
643
            ->will($this->returnValue(true));
644
645
        $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface');
646
        $this->cacheMock
647
            ->expects($this->at(3))
648
            ->method('getItem')
649
            ->with('content', 2, 1, ContentHandler::ALL_TRANSLATIONS_KEY)
650
            ->will($this->returnValue($cacheItemMock));
651
652
        $cacheItemMock
653
            ->expects($this->once())
654
            ->method('set')
655
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content'))
656
            ->will($this->returnValue($cacheItemMock));
657
658
        $cacheItemMock
659
            ->expects($this->once())
660
            ->method('save')
661
            ->with();
662
663
        $cacheItemMock
664
            ->expects($this->never())
665
            ->method('get');
666
667
        $cacheItemMock2 = $this->getMock('Stash\Interfaces\ItemInterface');
668
        $this->cacheMock
669
            ->expects($this->at(4))
670
            ->method('getItem')
671
            ->with('content', 'info', 2)
672
            ->will($this->returnValue($cacheItemMock2));
673
674
        $cacheItemMock2
675
            ->expects($this->once())
676
            ->method('set')
677
            ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ContentInfo'))
678
            ->will($this->returnValue($cacheItemMock2));
679
680
        $cacheItemMock2
681
            ->expects($this->once())
682
            ->method('save')
683
            ->with();
684
685
        $cacheItemMock2
686
            ->expects($this->never())
687
            ->method('get');
688
689
        $handler = $this->persistenceCacheHandler->contentHandler();
690
        $handler->publish(2, 1, new MetadataUpdateStruct());
691
    }
692
}
693