Code Duplication    Length = 22-28 lines in 21 locations

eZ/Publish/Core/Persistence/Cache/Tests/ContentTypeHandlerTest.php 10 locations

@@ 127-150 (lines=24) @@
124
    /**
125
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::deleteGroup
126
     */
127
    public function testDeleteGroup()
128
    {
129
        $this->loggerMock->expects($this->once())->method('logCall');
130
        $this->cacheMock
131
            ->expects($this->once())
132
            ->method('clear')
133
            ->with('contentTypeGroup', 55)
134
            ->will($this->returnValue(true));
135
136
        $innerHandler = $this->getContentTypeHandlerMock();
137
        $this->persistenceHandlerMock
138
            ->expects($this->once())
139
            ->method('contentTypeHandler')
140
            ->will($this->returnValue($innerHandler));
141
142
        $innerHandler
143
            ->expects($this->once())
144
            ->method('deleteGroup')
145
            ->with(55)
146
            ->will($this->returnValue(null));
147
148
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
149
        $handler->deleteGroup(55);
150
    }
151
152
    /**
153
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadGroup
@@ 244-265 (lines=22) @@
241
    /**
242
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadGroupByIdentifier
243
     */
244
    public function testLoadGroupByIdentifier()
245
    {
246
        $this->loggerMock->expects($this->once())->method('logCall');
247
        $this->cacheMock
248
            ->expects($this->never())
249
            ->method($this->anything());
250
251
        $innerHandler = $this->getContentTypeHandlerMock();
252
        $this->persistenceHandlerMock
253
            ->expects($this->once())
254
            ->method('contentTypeHandler')
255
            ->will($this->returnValue($innerHandler));
256
257
        $innerHandler
258
            ->expects($this->once())
259
            ->method('loadGroupByIdentifier')
260
            ->with('media')
261
            ->will($this->returnValue(null));
262
263
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
264
        $handler->loadGroupByIdentifier('media');
265
    }
266
267
    /**
268
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadAllGroups
@@ 296-317 (lines=22) @@
293
    /**
294
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadContentTypes
295
     */
296
    public function testLoadContentTypes()
297
    {
298
        $this->loggerMock->expects($this->once())->method('logCall');
299
        $this->cacheMock
300
            ->expects($this->never())
301
            ->method($this->anything());
302
303
        $innerHandler = $this->getContentTypeHandlerMock();
304
        $this->persistenceHandlerMock
305
            ->expects($this->once())
306
            ->method('contentTypeHandler')
307
            ->will($this->returnValue($innerHandler));
308
309
        $innerHandler
310
            ->expects($this->once())
311
            ->method('loadContentTypes')
312
            ->with(55)
313
            ->will($this->returnValue(array()));
314
315
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
316
        $handler->loadContentTypes(55);
317
    }
318
319
    /**
320
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load
@@ 590-611 (lines=22) @@
587
    /**
588
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadByRemoteId
589
     */
590
    public function testLoadByRemoteId()
591
    {
592
        $this->loggerMock->expects($this->once())->method('logCall');
593
        $this->cacheMock
594
            ->expects($this->never())
595
            ->method($this->anything());
596
597
        $innerHandler = $this->getContentTypeHandlerMock();
598
        $this->persistenceHandlerMock
599
            ->expects($this->once())
600
            ->method('contentTypeHandler')
601
            ->will($this->returnValue($innerHandler));
602
603
        $innerHandler
604
            ->expects($this->once())
605
            ->method('loadByRemoteId')
606
            ->with('cwr34ln43njntekwf')
607
            ->will($this->returnValue(null));
608
609
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
610
        $handler->loadByRemoteId('cwr34ln43njntekwf');
611
    }
612
613
    /**
614
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::create
@@ 908-929 (lines=22) @@
905
    /**
906
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::createDraft
907
     */
908
    public function testCreateDraft()
909
    {
910
        $this->loggerMock->expects($this->once())->method('logCall');
911
        $this->cacheMock
912
            ->expects($this->never())
913
            ->method($this->anything());
914
915
        $innerHandler = $this->getContentTypeHandlerMock();
916
        $this->persistenceHandlerMock
917
            ->expects($this->once())
918
            ->method('contentTypeHandler')
919
            ->will($this->returnValue($innerHandler));
920
921
        $innerHandler
922
            ->expects($this->once())
923
            ->method('createDraft')
924
            ->with(14, 33)
925
            ->will($this->returnValue(null));
926
927
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
928
        $handler->createDraft(14, 33);
929
    }
930
931
    /**
932
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::copy
@@ 934-955 (lines=22) @@
931
    /**
932
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::copy
933
     */
934
    public function testCopy()
935
    {
936
        $this->loggerMock->expects($this->once())->method('logCall');
937
        $this->cacheMock
938
            ->expects($this->never())
939
            ->method($this->anything());
940
941
        $innerHandler = $this->getContentTypeHandlerMock();
942
        $this->persistenceHandlerMock
943
            ->expects($this->once())
944
            ->method('contentTypeHandler')
945
            ->will($this->returnValue($innerHandler));
946
947
        $innerHandler
948
            ->expects($this->once())
949
            ->method('copy')
950
            ->with(14, 33, SPIType::STATUS_DEFINED)
951
            ->will($this->returnValue(null));
952
953
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
954
        $handler->copy(14, 33, SPIType::STATUS_DEFINED);
955
    }
956
957
    /**
958
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::link
@@ 990-1013 (lines=24) @@
987
    /**
988
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::link
989
     */
990
    public function testLinkDraft()
991
    {
992
        $this->loggerMock->expects($this->once())->method('logCall');
993
        $this->cacheMock
994
            ->expects($this->never())
995
            ->method($this->anything());
996
997
        $innerHandlerMock = $this->getContentTypeHandlerMock();
998
        $this->persistenceHandlerMock
999
            ->expects($this->once())
1000
            ->method('contentTypeHandler')
1001
            ->will($this->returnValue($innerHandlerMock));
1002
1003
        $innerHandlerMock
1004
            ->expects($this->once())
1005
            ->method('link')
1006
            ->with(22, 44, SPIType::STATUS_DRAFT)
1007
            ->will(
1008
                $this->returnValue(true)
1009
            );
1010
1011
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
1012
        $handler->link(22, 44, SPIType::STATUS_DRAFT);
1013
    }
1014
1015
    /**
1016
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::unlink
@@ 1048-1071 (lines=24) @@
1045
    /**
1046
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::unlink
1047
     */
1048
    public function testUnlinkDraft()
1049
    {
1050
        $this->loggerMock->expects($this->once())->method('logCall');
1051
        $this->cacheMock
1052
            ->expects($this->never())
1053
            ->method($this->anything());
1054
1055
        $innerHandlerMock = $this->getContentTypeHandlerMock();
1056
        $this->persistenceHandlerMock
1057
            ->expects($this->once())
1058
            ->method('contentTypeHandler')
1059
            ->will($this->returnValue($innerHandlerMock));
1060
1061
        $innerHandlerMock
1062
            ->expects($this->once())
1063
            ->method('unlink')
1064
            ->with(22, 44, SPIType::STATUS_DRAFT)
1065
            ->will(
1066
                $this->returnValue(true)
1067
            );
1068
1069
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
1070
        $handler->unlink(22, 44, SPIType::STATUS_DRAFT);
1071
    }
1072
1073
    /**
1074
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::getFieldDefinition
@@ 1214-1241 (lines=28) @@
1211
    /**
1212
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::removeFieldDefinition
1213
     */
1214
    public function testRemoveFieldDefinitionDraft()
1215
    {
1216
        $this->loggerMock->expects($this->once())->method('logCall');
1217
        $this->cacheMock
1218
            ->expects($this->never())
1219
            ->method($this->anything());
1220
1221
        $innerHandlerMock = $this->getContentTypeHandlerMock();
1222
        $this->persistenceHandlerMock
1223
            ->expects($this->once())
1224
            ->method('contentTypeHandler')
1225
            ->will($this->returnValue($innerHandlerMock));
1226
1227
        $innerHandlerMock
1228
            ->expects($this->once())
1229
            ->method('removeFieldDefinition')
1230
            ->with(
1231
                44,
1232
                SPIType::STATUS_DRAFT,
1233
                33
1234
            )
1235
            ->will(
1236
                $this->returnValue(true)
1237
            );
1238
1239
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
1240
        $handler->removeFieldDefinition(44, SPIType::STATUS_DRAFT, 33);
1241
    }
1242
1243
    /**
1244
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::updateFieldDefinition
@@ 1366-1387 (lines=22) @@
1363
    /**
1364
     * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::getContentCount
1365
     */
1366
    public function testGetContentCount()
1367
    {
1368
        $this->loggerMock->expects($this->once())->method('logCall');
1369
        $this->cacheMock
1370
            ->expects($this->never())
1371
            ->method($this->anything());
1372
1373
        $innerHandler = $this->getContentTypeHandlerMock();
1374
        $this->persistenceHandlerMock
1375
            ->expects($this->once())
1376
            ->method('contentTypeHandler')
1377
            ->will($this->returnValue($innerHandler));
1378
1379
        $innerHandler
1380
            ->expects($this->once())
1381
            ->method('getContentCount')
1382
            ->with(1)
1383
            ->will($this->returnValue(18));
1384
1385
        $handler = $this->persistenceCacheHandler->contentTypeHandler();
1386
        $handler->getContentCount(1);
1387
    }
1388
}
1389

eZ/Publish/Core/Persistence/Cache/Tests/LocationHandlerTest.php 6 locations

@@ 446-467 (lines=22) @@
443
    /**
444
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::loadByRemoteId
445
     */
446
    public function testLoadByRemoteId()
447
    {
448
        $this->loggerMock->expects($this->once())->method('logCall');
449
        $this->cacheMock
450
            ->expects($this->never())
451
            ->method($this->anything());
452
453
        $innerHandler = $this->getSPILocationHandlerMock();
454
        $this->persistenceHandlerMock
455
            ->expects($this->once())
456
            ->method('locationHandler')
457
            ->will($this->returnValue($innerHandler));
458
459
        $innerHandler
460
            ->expects($this->once())
461
            ->method('loadByRemoteId')
462
            ->with('sve45gdy4e')
463
            ->will($this->returnValue(new Location(array('id' => 33))));
464
465
        $handler = $this->persistenceCacheHandler->locationHandler();
466
        $handler->loadByRemoteId('sve45gdy4e');
467
    }
468
469
    /**
470
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::copySubtree
@@ 472-493 (lines=22) @@
469
    /**
470
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::copySubtree
471
     */
472
    public function testCopySubtree()
473
    {
474
        $this->loggerMock->expects($this->once())->method('logCall');
475
        $this->cacheMock
476
            ->expects($this->never())
477
            ->method($this->anything());
478
479
        $innerHandler = $this->getSPILocationHandlerMock();
480
        $this->persistenceHandlerMock
481
            ->expects($this->once())
482
            ->method('locationHandler')
483
            ->will($this->returnValue($innerHandler));
484
485
        $innerHandler
486
            ->expects($this->once())
487
            ->method('copySubtree')
488
            ->with(55, 66)
489
            ->will($this->returnValue(null));
490
491
        $handler = $this->persistenceCacheHandler->locationHandler();
492
        $handler->copySubtree(55, 66);
493
    }
494
495
    /**
496
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::move
@@ 538-559 (lines=22) @@
535
    /**
536
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::markSubtreeModified
537
     */
538
    public function testMarkSubtreeModified()
539
    {
540
        $this->loggerMock->expects($this->once())->method('logCall');
541
        $this->cacheMock
542
            ->expects($this->never())
543
            ->method($this->anything());
544
545
        $innerHandler = $this->getSPILocationHandlerMock();
546
        $this->persistenceHandlerMock
547
            ->expects($this->once())
548
            ->method('locationHandler')
549
            ->will($this->returnValue($innerHandler));
550
551
        $innerHandler
552
            ->expects($this->once())
553
            ->method('markSubtreeModified')
554
            ->with(55)
555
            ->will($this->returnValue(null));
556
557
        $handler = $this->persistenceCacheHandler->locationHandler();
558
        $handler->markSubtreeModified(55);
559
    }
560
561
    /**
562
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::hide
@@ 564-587 (lines=24) @@
561
    /**
562
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::hide
563
     */
564
    public function testHide()
565
    {
566
        $this->loggerMock->expects($this->once())->method('logCall');
567
        $this->cacheMock
568
            ->expects($this->once())
569
            ->method('clear')
570
            ->with('location')
571
            ->will($this->returnValue(true));
572
573
        $innerHandlerMock = $this->getSPILocationHandlerMock();
574
        $this->persistenceHandlerMock
575
            ->expects($this->once())
576
            ->method('locationHandler')
577
            ->will($this->returnValue($innerHandlerMock));
578
579
        $innerHandlerMock
580
            ->expects($this->once())
581
            ->method('hide')
582
            ->with(33)
583
            ->will($this->returnValue(true));
584
585
        $handler = $this->persistenceCacheHandler->locationHandler();
586
        $handler->hide(33);
587
    }
588
589
    /**
590
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::unhide
@@ 592-615 (lines=24) @@
589
    /**
590
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::unhide
591
     */
592
    public function testUnhide()
593
    {
594
        $this->loggerMock->expects($this->once())->method('logCall');
595
        $this->cacheMock
596
            ->expects($this->once())
597
            ->method('clear')
598
            ->with('location')
599
            ->will($this->returnValue(true));
600
601
        $innerHandlerMock = $this->getSPILocationHandlerMock();
602
        $this->persistenceHandlerMock
603
            ->expects($this->once())
604
            ->method('locationHandler')
605
            ->will($this->returnValue($innerHandlerMock));
606
607
        $innerHandlerMock
608
            ->expects($this->once())
609
            ->method('unhide')
610
            ->with(33)
611
            ->will($this->returnValue(true));
612
613
        $handler = $this->persistenceCacheHandler->locationHandler();
614
        $handler->unhide(33);
615
    }
616
617
    /**
618
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::swap
@@ 877-899 (lines=23) @@
874
    /**
875
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::setSectionForSubtree
876
     */
877
    public function testSetSectionForSubtree()
878
    {
879
        $this->loggerMock->expects($this->once())->method('logCall');
880
        $this->cacheMock
881
            ->expects($this->once())
882
            ->method('clear')
883
            ->with('content');
884
885
        $innerHandler = $this->getSPILocationHandlerMock();
886
        $this->persistenceHandlerMock
887
            ->expects($this->once())
888
            ->method('locationHandler')
889
            ->will($this->returnValue($innerHandler));
890
891
        $innerHandler
892
            ->expects($this->once())
893
            ->method('setSectionForSubtree')
894
            ->with(33, 2)
895
            ->will($this->returnValue(null));
896
897
        $handler = $this->persistenceCacheHandler->locationHandler();
898
        $handler->setSectionForSubtree(33, 2);
899
    }
900
901
    /**
902
     * @covers \eZ\Publish\Core\Persistence\Cache\LocationHandler::changeMainLocation

eZ/Publish/Core/Persistence/Cache/Tests/SectionHandlerTest.php 4 locations

@@ 63-84 (lines=22) @@
60
    /**
61
     * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::assignmentsCount
62
     */
63
    public function testAssignmentsCount()
64
    {
65
        $this->loggerMock->expects($this->once())->method('logCall');
66
        $this->cacheMock
67
            ->expects($this->never())
68
            ->method($this->anything());
69
70
        $innerHandler = $this->getSPISectionHandlerMock();
71
        $this->persistenceHandlerMock
72
            ->expects($this->once())
73
            ->method('sectionHandler')
74
            ->will($this->returnValue($innerHandler));
75
76
        $innerHandler
77
            ->expects($this->once())
78
            ->method('assignmentsCount')
79
            ->with(33)
80
            ->will($this->returnValue(null));
81
82
        $handler = $this->persistenceCacheHandler->sectionHandler();
83
        $handler->assignmentsCount(33);
84
    }
85
86
    /**
87
     * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::policiesCount
@@ 89-110 (lines=22) @@
86
    /**
87
     * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::policiesCount
88
     */
89
    public function testPoliciesCount()
90
    {
91
        $this->loggerMock->expects($this->once())->method('logCall');
92
        $this->cacheMock
93
            ->expects($this->never())
94
            ->method($this->anything());
95
96
        $innerHandler = $this->getSPISectionHandlerMock();
97
        $this->persistenceHandlerMock
98
            ->expects($this->once())
99
            ->method('sectionHandler')
100
            ->will($this->returnValue($innerHandler));
101
102
        $innerHandler
103
            ->expects($this->once())
104
            ->method('policiesCount')
105
            ->with(1)
106
            ->will($this->returnValue(7));
107
108
        $handler = $this->persistenceCacheHandler->sectionHandler();
109
        $handler->policiesCount(1);
110
    }
111
112
    /**
113
     * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::countRoleAssignmentsUsingSection
@@ 115-136 (lines=22) @@
112
    /**
113
     * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::countRoleAssignmentsUsingSection
114
     */
115
    public function testCountRoleAssignmentsUsingSection()
116
    {
117
        $this->loggerMock->expects($this->once())->method('logCall');
118
        $this->cacheMock
119
            ->expects($this->never())
120
            ->method($this->anything());
121
122
        $innerHandler = $this->getSPISectionHandlerMock();
123
        $this->persistenceHandlerMock
124
            ->expects($this->once())
125
            ->method('sectionHandler')
126
            ->will($this->returnValue($innerHandler));
127
128
        $innerHandler
129
            ->expects($this->once())
130
            ->method('countRoleAssignmentsUsingSection')
131
            ->with(1)
132
            ->will($this->returnValue(0));
133
134
        $handler = $this->persistenceCacheHandler->sectionHandler();
135
        $handler->countRoleAssignmentsUsingSection(1);
136
    }
137
138
    /**
139
     * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::create
@@ 192-218 (lines=27) @@
189
    /**
190
     * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::delete
191
     */
192
    public function testDelete()
193
    {
194
        $this->loggerMock->expects($this->once())->method('logCall');
195
196
        $innerHandlerMock = $this->getSPISectionHandlerMock();
197
        $this->persistenceHandlerMock
198
            ->expects($this->once())
199
            ->method('sectionHandler')
200
            ->will($this->returnValue($innerHandlerMock));
201
202
        $innerHandlerMock
203
            ->expects($this->once())
204
            ->method('delete')
205
            ->with(33)
206
            ->will(
207
                $this->returnValue(true)
208
            );
209
210
        $this->cacheMock
211
            ->expects($this->once())
212
            ->method('clear')
213
            ->with('section', 33)
214
            ->will($this->returnValue(true));
215
216
        $handler = $this->persistenceCacheHandler->sectionHandler();
217
        $handler->delete(33);
218
    }
219
220
    /**
221
     * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::load

eZ/Publish/Core/Persistence/Cache/Tests/UserHandlerTest.php 1 location

@@ 925-951 (lines=27) @@
922
    /**
923
     * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::deletePolicy
924
     */
925
    public function testDeletePolicy()
926
    {
927
        $this->loggerMock->expects($this->once())->method('logCall');
928
929
        $innerHandlerMock = $this->getSPIUserHandlerMock();
930
        $this->persistenceHandlerMock
931
            ->expects($this->once())
932
            ->method('userHandler')
933
            ->will($this->returnValue($innerHandlerMock));
934
935
        $innerHandlerMock
936
            ->expects($this->once())
937
            ->method('deletePolicy')
938
            ->with(55)
939
            ->will(
940
                $this->returnValue(true)
941
            );
942
943
        $this->cacheMock
944
            ->expects($this->once())
945
            ->method('clear')
946
            ->with('user', 'role')
947
            ->will($this->returnValue(true));
948
949
        $handler = $this->persistenceCacheHandler->userHandler();
950
        $handler->deletePolicy(55);
951
    }
952
953
    /**
954
     * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::assignRole