Code Duplication    Length = 28-29 lines in 26 locations

eZ/Publish/Core/Event/Tests/ContentServiceTest.php 5 locations

@@ 148-176 (lines=29) @@
145
        ]);
146
    }
147
148
    public function testCopyContentEvents()
149
    {
150
        $traceableEventDispatcher = $this->getEventDispatcher(
151
            BeforeCopyContentEvent::class,
152
            CopyContentEvent::class
153
        );
154
155
        $parameters = [
156
            $this->createMock(ContentInfo::class),
157
            $this->createMock(LocationCreateStruct::class),
158
            $this->createMock(VersionInfo::class),
159
        ];
160
161
        $content = $this->createMock(Content::class);
162
        $innerServiceMock = $this->createMock(ContentServiceInterface::class);
163
        $innerServiceMock->method('copyContent')->willReturn($content);
164
165
        $service = new ContentService($innerServiceMock, $traceableEventDispatcher);
166
        $result = $service->copyContent(...$parameters);
167
168
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
169
170
        $this->assertSame($content, $result);
171
        $this->assertSame($calledListeners, [
172
            [BeforeCopyContentEvent::class, 0],
173
            [CopyContentEvent::class, 0],
174
        ]);
175
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
176
    }
177
178
    public function testReturnCopyContentResultInBeforeEvents()
179
    {
@@ 253-280 (lines=28) @@
250
        ]);
251
    }
252
253
    public function testUpdateContentEvents()
254
    {
255
        $traceableEventDispatcher = $this->getEventDispatcher(
256
            BeforeUpdateContentEvent::class,
257
            UpdateContentEvent::class
258
        );
259
260
        $parameters = [
261
            $this->createMock(VersionInfo::class),
262
            $this->createMock(ContentUpdateStruct::class),
263
        ];
264
265
        $content = $this->createMock(Content::class);
266
        $innerServiceMock = $this->createMock(ContentServiceInterface::class);
267
        $innerServiceMock->method('updateContent')->willReturn($content);
268
269
        $service = new ContentService($innerServiceMock, $traceableEventDispatcher);
270
        $result = $service->updateContent(...$parameters);
271
272
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
273
274
        $this->assertSame($content, $result);
275
        $this->assertSame($calledListeners, [
276
            [BeforeUpdateContentEvent::class, 0],
277
            [UpdateContentEvent::class, 0],
278
        ]);
279
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
280
    }
281
282
    public function testReturnUpdateContentResultInBeforeEvents()
283
    {
@@ 630-657 (lines=28) @@
627
        ]);
628
    }
629
630
    public function testAddRelationEvents()
631
    {
632
        $traceableEventDispatcher = $this->getEventDispatcher(
633
            BeforeAddRelationEvent::class,
634
            AddRelationEvent::class
635
        );
636
637
        $parameters = [
638
            $this->createMock(VersionInfo::class),
639
            $this->createMock(ContentInfo::class),
640
        ];
641
642
        $relation = $this->createMock(Relation::class);
643
        $innerServiceMock = $this->createMock(ContentServiceInterface::class);
644
        $innerServiceMock->method('addRelation')->willReturn($relation);
645
646
        $service = new ContentService($innerServiceMock, $traceableEventDispatcher);
647
        $result = $service->addRelation(...$parameters);
648
649
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
650
651
        $this->assertSame($relation, $result);
652
        $this->assertSame($calledListeners, [
653
            [BeforeAddRelationEvent::class, 0],
654
            [AddRelationEvent::class, 0],
655
        ]);
656
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
657
    }
658
659
    public function testReturnAddRelationResultInBeforeEvents()
660
    {
@@ 732-759 (lines=28) @@
729
        ]);
730
    }
731
732
    public function testUpdateContentMetadataEvents()
733
    {
734
        $traceableEventDispatcher = $this->getEventDispatcher(
735
            BeforeUpdateContentMetadataEvent::class,
736
            UpdateContentMetadataEvent::class
737
        );
738
739
        $parameters = [
740
            $this->createMock(ContentInfo::class),
741
            $this->createMock(ContentMetadataUpdateStruct::class),
742
        ];
743
744
        $content = $this->createMock(Content::class);
745
        $innerServiceMock = $this->createMock(ContentServiceInterface::class);
746
        $innerServiceMock->method('updateContentMetadata')->willReturn($content);
747
748
        $service = new ContentService($innerServiceMock, $traceableEventDispatcher);
749
        $result = $service->updateContentMetadata(...$parameters);
750
751
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
752
753
        $this->assertSame($content, $result);
754
        $this->assertSame($calledListeners, [
755
            [BeforeUpdateContentMetadataEvent::class, 0],
756
            [UpdateContentMetadataEvent::class, 0],
757
        ]);
758
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
759
    }
760
761
    public function testReturnUpdateContentMetadataResultInBeforeEvents()
762
    {
@@ 992-1020 (lines=29) @@
989
        ]);
990
    }
991
992
    public function testCreateContentDraftEvents()
993
    {
994
        $traceableEventDispatcher = $this->getEventDispatcher(
995
            BeforeCreateContentDraftEvent::class,
996
            CreateContentDraftEvent::class
997
        );
998
999
        $parameters = [
1000
            $this->createMock(ContentInfo::class),
1001
            $this->createMock(VersionInfo::class),
1002
            $this->createMock(User::class),
1003
        ];
1004
1005
        $contentDraft = $this->createMock(Content::class);
1006
        $innerServiceMock = $this->createMock(ContentServiceInterface::class);
1007
        $innerServiceMock->method('createContentDraft')->willReturn($contentDraft);
1008
1009
        $service = new ContentService($innerServiceMock, $traceableEventDispatcher);
1010
        $result = $service->createContentDraft(...$parameters);
1011
1012
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
1013
1014
        $this->assertSame($contentDraft, $result);
1015
        $this->assertSame($calledListeners, [
1016
            [BeforeCreateContentDraftEvent::class, 0],
1017
            [CreateContentDraftEvent::class, 0],
1018
        ]);
1019
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
1020
    }
1021
1022
    public function testReturnCreateContentDraftResultInBeforeEvents()
1023
    {

eZ/Publish/Core/Event/Tests/ContentTypeServiceTest.php 1 location

@@ 1043-1070 (lines=28) @@
1040
        ]);
1041
    }
1042
1043
    public function testCopyContentTypeEvents()
1044
    {
1045
        $traceableEventDispatcher = $this->getEventDispatcher(
1046
            BeforeCopyContentTypeEvent::class,
1047
            CopyContentTypeEvent::class
1048
        );
1049
1050
        $parameters = [
1051
            $this->createMock(ContentType::class),
1052
            $this->createMock(User::class),
1053
        ];
1054
1055
        $contentTypeCopy = $this->createMock(ContentType::class);
1056
        $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class);
1057
        $innerServiceMock->method('copyContentType')->willReturn($contentTypeCopy);
1058
1059
        $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher);
1060
        $result = $service->copyContentType(...$parameters);
1061
1062
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
1063
1064
        $this->assertSame($contentTypeCopy, $result);
1065
        $this->assertSame($calledListeners, [
1066
            [BeforeCopyContentTypeEvent::class, 0],
1067
            [CopyContentTypeEvent::class, 0],
1068
        ]);
1069
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
1070
    }
1071
1072
    public function testReturnCopyContentTypeResultInBeforeEvents()
1073
    {

eZ/Publish/Core/Event/Tests/LocationServiceTest.php 3 locations

@@ 34-61 (lines=28) @@
31
32
class LocationServiceTest extends AbstractServiceTest
33
{
34
    public function testCopySubtreeEvents()
35
    {
36
        $traceableEventDispatcher = $this->getEventDispatcher(
37
            BeforeCopySubtreeEvent::class,
38
            CopySubtreeEvent::class
39
        );
40
41
        $parameters = [
42
            $this->createMock(Location::class),
43
            $this->createMock(Location::class),
44
        ];
45
46
        $location = $this->createMock(Location::class);
47
        $innerServiceMock = $this->createMock(LocationServiceInterface::class);
48
        $innerServiceMock->method('copySubtree')->willReturn($location);
49
50
        $service = new LocationService($innerServiceMock, $traceableEventDispatcher);
51
        $result = $service->copySubtree(...$parameters);
52
53
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
54
55
        $this->assertSame($location, $result);
56
        $this->assertSame($calledListeners, [
57
            [BeforeCopySubtreeEvent::class, 0],
58
            [CopySubtreeEvent::class, 0],
59
        ]);
60
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
61
    }
62
63
    public function testReturnCopySubtreeResultInBeforeEvents()
64
    {
@@ 509-536 (lines=28) @@
506
        ]);
507
    }
508
509
    public function testUpdateLocationEvents()
510
    {
511
        $traceableEventDispatcher = $this->getEventDispatcher(
512
            BeforeUpdateLocationEvent::class,
513
            UpdateLocationEvent::class
514
        );
515
516
        $parameters = [
517
            $this->createMock(Location::class),
518
            $this->createMock(LocationUpdateStruct::class),
519
        ];
520
521
        $updatedLocation = $this->createMock(Location::class);
522
        $innerServiceMock = $this->createMock(LocationServiceInterface::class);
523
        $innerServiceMock->method('updateLocation')->willReturn($updatedLocation);
524
525
        $service = new LocationService($innerServiceMock, $traceableEventDispatcher);
526
        $result = $service->updateLocation(...$parameters);
527
528
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
529
530
        $this->assertSame($updatedLocation, $result);
531
        $this->assertSame($calledListeners, [
532
            [BeforeUpdateLocationEvent::class, 0],
533
            [UpdateLocationEvent::class, 0],
534
        ]);
535
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
536
    }
537
538
    public function testReturnUpdateLocationResultInBeforeEvents()
539
    {
@@ 611-638 (lines=28) @@
608
        ]);
609
    }
610
611
    public function testCreateLocationEvents()
612
    {
613
        $traceableEventDispatcher = $this->getEventDispatcher(
614
            BeforeCreateLocationEvent::class,
615
            CreateLocationEvent::class
616
        );
617
618
        $parameters = [
619
            $this->createMock(ContentInfo::class),
620
            $this->createMock(LocationCreateStruct::class),
621
        ];
622
623
        $location = $this->createMock(Location::class);
624
        $innerServiceMock = $this->createMock(LocationServiceInterface::class);
625
        $innerServiceMock->method('createLocation')->willReturn($location);
626
627
        $service = new LocationService($innerServiceMock, $traceableEventDispatcher);
628
        $result = $service->createLocation(...$parameters);
629
630
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
631
632
        $this->assertSame($location, $result);
633
        $this->assertSame($calledListeners, [
634
            [BeforeCreateLocationEvent::class, 0],
635
            [CreateLocationEvent::class, 0],
636
        ]);
637
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
638
    }
639
640
    public function testReturnCreateLocationResultInBeforeEvents()
641
    {

eZ/Publish/Core/Event/Tests/ObjectStateServiceTest.php 3 locations

@@ 197-224 (lines=28) @@
194
        ]);
195
    }
196
197
    public function testUpdateObjectStateEvents()
198
    {
199
        $traceableEventDispatcher = $this->getEventDispatcher(
200
            BeforeUpdateObjectStateEvent::class,
201
            UpdateObjectStateEvent::class
202
        );
203
204
        $parameters = [
205
            $this->createMock(ObjectState::class),
206
            $this->createMock(ObjectStateUpdateStruct::class),
207
        ];
208
209
        $updatedObjectState = $this->createMock(ObjectState::class);
210
        $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class);
211
        $innerServiceMock->method('updateObjectState')->willReturn($updatedObjectState);
212
213
        $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher);
214
        $result = $service->updateObjectState(...$parameters);
215
216
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
217
218
        $this->assertSame($updatedObjectState, $result);
219
        $this->assertSame($calledListeners, [
220
            [BeforeUpdateObjectStateEvent::class, 0],
221
            [UpdateObjectStateEvent::class, 0],
222
        ]);
223
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
224
    }
225
226
    public function testReturnUpdateObjectStateResultInBeforeEvents()
227
    {
@@ 299-326 (lines=28) @@
296
        ]);
297
    }
298
299
    public function testCreateObjectStateEvents()
300
    {
301
        $traceableEventDispatcher = $this->getEventDispatcher(
302
            BeforeCreateObjectStateEvent::class,
303
            CreateObjectStateEvent::class
304
        );
305
306
        $parameters = [
307
            $this->createMock(ObjectStateGroup::class),
308
            $this->createMock(ObjectStateCreateStruct::class),
309
        ];
310
311
        $objectState = $this->createMock(ObjectState::class);
312
        $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class);
313
        $innerServiceMock->method('createObjectState')->willReturn($objectState);
314
315
        $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher);
316
        $result = $service->createObjectState(...$parameters);
317
318
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
319
320
        $this->assertSame($objectState, $result);
321
        $this->assertSame($calledListeners, [
322
            [BeforeCreateObjectStateEvent::class, 0],
323
            [CreateObjectStateEvent::class, 0],
324
        ]);
325
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
326
    }
327
328
    public function testReturnCreateObjectStateResultInBeforeEvents()
329
    {
@@ 401-428 (lines=28) @@
398
        ]);
399
    }
400
401
    public function testUpdateObjectStateGroupEvents()
402
    {
403
        $traceableEventDispatcher = $this->getEventDispatcher(
404
            BeforeUpdateObjectStateGroupEvent::class,
405
            UpdateObjectStateGroupEvent::class
406
        );
407
408
        $parameters = [
409
            $this->createMock(ObjectStateGroup::class),
410
            $this->createMock(ObjectStateGroupUpdateStruct::class),
411
        ];
412
413
        $updatedObjectStateGroup = $this->createMock(ObjectStateGroup::class);
414
        $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class);
415
        $innerServiceMock->method('updateObjectStateGroup')->willReturn($updatedObjectStateGroup);
416
417
        $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher);
418
        $result = $service->updateObjectStateGroup(...$parameters);
419
420
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
421
422
        $this->assertSame($updatedObjectStateGroup, $result);
423
        $this->assertSame($calledListeners, [
424
            [BeforeUpdateObjectStateGroupEvent::class, 0],
425
            [UpdateObjectStateGroupEvent::class, 0],
426
        ]);
427
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
428
    }
429
430
    public function testReturnUpdateObjectStateGroupResultInBeforeEvents()
431
    {

eZ/Publish/Core/Event/Tests/RoleServiceTest.php 7 locations

@@ 119-146 (lines=28) @@
116
        ]);
117
    }
118
119
    public function testUpdateRoleEvents()
120
    {
121
        $traceableEventDispatcher = $this->getEventDispatcher(
122
            BeforeUpdateRoleEvent::class,
123
            UpdateRoleEvent::class
124
        );
125
126
        $parameters = [
127
            $this->createMock(Role::class),
128
            $this->createMock(RoleUpdateStruct::class),
129
        ];
130
131
        $updatedRole = $this->createMock(Role::class);
132
        $innerServiceMock = $this->createMock(RoleServiceInterface::class);
133
        $innerServiceMock->method('updateRole')->willReturn($updatedRole);
134
135
        $service = new RoleService($innerServiceMock, $traceableEventDispatcher);
136
        $result = $service->updateRole(...$parameters);
137
138
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
139
140
        $this->assertSame($updatedRole, $result);
141
        $this->assertSame($calledListeners, [
142
            [BeforeUpdateRoleEvent::class, 0],
143
            [UpdateRoleEvent::class, 0],
144
        ]);
145
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
146
    }
147
148
    public function testReturnUpdateRoleResultInBeforeEvents()
149
    {
@@ 339-366 (lines=28) @@
336
        ]);
337
    }
338
339
    public function testAddPolicyEvents()
340
    {
341
        $traceableEventDispatcher = $this->getEventDispatcher(
342
            BeforeAddPolicyEvent::class,
343
            AddPolicyEvent::class
344
        );
345
346
        $parameters = [
347
            $this->createMock(Role::class),
348
            $this->createMock(PolicyCreateStruct::class),
349
        ];
350
351
        $updatedRole = $this->createMock(Role::class);
352
        $innerServiceMock = $this->createMock(RoleServiceInterface::class);
353
        $innerServiceMock->method('addPolicy')->willReturn($updatedRole);
354
355
        $service = new RoleService($innerServiceMock, $traceableEventDispatcher);
356
        $result = $service->addPolicy(...$parameters);
357
358
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
359
360
        $this->assertSame($updatedRole, $result);
361
        $this->assertSame($calledListeners, [
362
            [BeforeAddPolicyEvent::class, 0],
363
            [AddPolicyEvent::class, 0],
364
        ]);
365
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
366
    }
367
368
    public function testReturnAddPolicyResultInBeforeEvents()
369
    {
@@ 441-468 (lines=28) @@
438
        ]);
439
    }
440
441
    public function testUpdateRoleDraftEvents()
442
    {
443
        $traceableEventDispatcher = $this->getEventDispatcher(
444
            BeforeUpdateRoleDraftEvent::class,
445
            UpdateRoleDraftEvent::class
446
        );
447
448
        $parameters = [
449
            $this->createMock(RoleDraft::class),
450
            $this->createMock(RoleUpdateStruct::class),
451
        ];
452
453
        $updatedRoleDraft = $this->createMock(RoleDraft::class);
454
        $innerServiceMock = $this->createMock(RoleServiceInterface::class);
455
        $innerServiceMock->method('updateRoleDraft')->willReturn($updatedRoleDraft);
456
457
        $service = new RoleService($innerServiceMock, $traceableEventDispatcher);
458
        $result = $service->updateRoleDraft(...$parameters);
459
460
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
461
462
        $this->assertSame($updatedRoleDraft, $result);
463
        $this->assertSame($calledListeners, [
464
            [BeforeUpdateRoleDraftEvent::class, 0],
465
            [UpdateRoleDraftEvent::class, 0],
466
        ]);
467
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
468
    }
469
470
    public function testReturnUpdateRoleDraftResultInBeforeEvents()
471
    {
@@ 663-691 (lines=29) @@
660
        ]);
661
    }
662
663
    public function testUpdatePolicyByRoleDraftEvents()
664
    {
665
        $traceableEventDispatcher = $this->getEventDispatcher(
666
            BeforeUpdatePolicyByRoleDraftEvent::class,
667
            UpdatePolicyByRoleDraftEvent::class
668
        );
669
670
        $parameters = [
671
            $this->createMock(RoleDraft::class),
672
            $this->createMock(PolicyDraft::class),
673
            $this->createMock(PolicyUpdateStruct::class),
674
        ];
675
676
        $updatedPolicyDraft = $this->createMock(PolicyDraft::class);
677
        $innerServiceMock = $this->createMock(RoleServiceInterface::class);
678
        $innerServiceMock->method('updatePolicyByRoleDraft')->willReturn($updatedPolicyDraft);
679
680
        $service = new RoleService($innerServiceMock, $traceableEventDispatcher);
681
        $result = $service->updatePolicyByRoleDraft(...$parameters);
682
683
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
684
685
        $this->assertSame($updatedPolicyDraft, $result);
686
        $this->assertSame($calledListeners, [
687
            [BeforeUpdatePolicyByRoleDraftEvent::class, 0],
688
            [UpdatePolicyByRoleDraftEvent::class, 0],
689
        ]);
690
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
691
    }
692
693
    public function testReturnUpdatePolicyByRoleDraftResultInBeforeEvents()
694
    {
@@ 867-894 (lines=28) @@
864
        ]);
865
    }
866
867
    public function testRemovePolicyByRoleDraftEvents()
868
    {
869
        $traceableEventDispatcher = $this->getEventDispatcher(
870
            BeforeRemovePolicyByRoleDraftEvent::class,
871
            RemovePolicyByRoleDraftEvent::class
872
        );
873
874
        $parameters = [
875
            $this->createMock(RoleDraft::class),
876
            $this->createMock(PolicyDraft::class),
877
        ];
878
879
        $updatedRoleDraft = $this->createMock(RoleDraft::class);
880
        $innerServiceMock = $this->createMock(RoleServiceInterface::class);
881
        $innerServiceMock->method('removePolicyByRoleDraft')->willReturn($updatedRoleDraft);
882
883
        $service = new RoleService($innerServiceMock, $traceableEventDispatcher);
884
        $result = $service->removePolicyByRoleDraft(...$parameters);
885
886
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
887
888
        $this->assertSame($updatedRoleDraft, $result);
889
        $this->assertSame($calledListeners, [
890
            [BeforeRemovePolicyByRoleDraftEvent::class, 0],
891
            [RemovePolicyByRoleDraftEvent::class, 0],
892
        ]);
893
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
894
    }
895
896
    public function testReturnRemovePolicyByRoleDraftResultInBeforeEvents()
897
    {
@@ 969-996 (lines=28) @@
966
        ]);
967
    }
968
969
    public function testAddPolicyByRoleDraftEvents()
970
    {
971
        $traceableEventDispatcher = $this->getEventDispatcher(
972
            BeforeAddPolicyByRoleDraftEvent::class,
973
            AddPolicyByRoleDraftEvent::class
974
        );
975
976
        $parameters = [
977
            $this->createMock(RoleDraft::class),
978
            $this->createMock(PolicyCreateStruct::class),
979
        ];
980
981
        $updatedRoleDraft = $this->createMock(RoleDraft::class);
982
        $innerServiceMock = $this->createMock(RoleServiceInterface::class);
983
        $innerServiceMock->method('addPolicyByRoleDraft')->willReturn($updatedRoleDraft);
984
985
        $service = new RoleService($innerServiceMock, $traceableEventDispatcher);
986
        $result = $service->addPolicyByRoleDraft(...$parameters);
987
988
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
989
990
        $this->assertSame($updatedRoleDraft, $result);
991
        $this->assertSame($calledListeners, [
992
            [BeforeAddPolicyByRoleDraftEvent::class, 0],
993
            [AddPolicyByRoleDraftEvent::class, 0],
994
        ]);
995
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
996
    }
997
998
    public function testReturnAddPolicyByRoleDraftResultInBeforeEvents()
999
    {
@@ 1341-1368 (lines=28) @@
1338
        ]);
1339
    }
1340
1341
    public function testUpdatePolicyEvents()
1342
    {
1343
        $traceableEventDispatcher = $this->getEventDispatcher(
1344
            BeforeUpdatePolicyEvent::class,
1345
            UpdatePolicyEvent::class
1346
        );
1347
1348
        $parameters = [
1349
            $this->createMock(Policy::class),
1350
            $this->createMock(PolicyUpdateStruct::class),
1351
        ];
1352
1353
        $updatedPolicy = $this->createMock(Policy::class);
1354
        $innerServiceMock = $this->createMock(RoleServiceInterface::class);
1355
        $innerServiceMock->method('updatePolicy')->willReturn($updatedPolicy);
1356
1357
        $service = new RoleService($innerServiceMock, $traceableEventDispatcher);
1358
        $result = $service->updatePolicy(...$parameters);
1359
1360
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
1361
1362
        $this->assertSame($updatedPolicy, $result);
1363
        $this->assertSame($calledListeners, [
1364
            [BeforeUpdatePolicyEvent::class, 0],
1365
            [UpdatePolicyEvent::class, 0],
1366
        ]);
1367
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
1368
    }
1369
1370
    public function testReturnUpdatePolicyResultInBeforeEvents()
1371
    {

eZ/Publish/Core/Event/Tests/SectionServiceTest.php 1 location

@@ 88-115 (lines=28) @@
85
        ]);
86
    }
87
88
    public function testUpdateSectionEvents()
89
    {
90
        $traceableEventDispatcher = $this->getEventDispatcher(
91
            BeforeUpdateSectionEvent::class,
92
            UpdateSectionEvent::class
93
        );
94
95
        $parameters = [
96
            $this->createMock(Section::class),
97
            $this->createMock(SectionUpdateStruct::class),
98
        ];
99
100
        $updatedSection = $this->createMock(Section::class);
101
        $innerServiceMock = $this->createMock(SectionServiceInterface::class);
102
        $innerServiceMock->method('updateSection')->willReturn($updatedSection);
103
104
        $service = new SectionService($innerServiceMock, $traceableEventDispatcher);
105
        $result = $service->updateSection(...$parameters);
106
107
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
108
109
        $this->assertSame($updatedSection, $result);
110
        $this->assertSame($calledListeners, [
111
            [BeforeUpdateSectionEvent::class, 0],
112
            [UpdateSectionEvent::class, 0],
113
        ]);
114
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
115
    }
116
117
    public function testReturnUpdateSectionResultInBeforeEvents()
118
    {

eZ/Publish/Core/Event/Tests/TrashServiceTest.php 1 location

@@ 221-248 (lines=28) @@
218
        ]);
219
    }
220
221
    public function testRecoverEvents()
222
    {
223
        $traceableEventDispatcher = $this->getEventDispatcher(
224
            BeforeRecoverEvent::class,
225
            RecoverEvent::class
226
        );
227
228
        $parameters = [
229
            $this->createMock(TrashItem::class),
230
            $this->createMock(Location::class),
231
        ];
232
233
        $location = $this->createMock(Location::class);
234
        $innerServiceMock = $this->createMock(TrashServiceInterface::class);
235
        $innerServiceMock->method('recover')->willReturn($location);
236
237
        $service = new TrashService($innerServiceMock, $traceableEventDispatcher);
238
        $result = $service->recover(...$parameters);
239
240
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
241
242
        $this->assertSame($location, $result);
243
        $this->assertSame($calledListeners, [
244
            [BeforeRecoverEvent::class, 0],
245
            [RecoverEvent::class, 0],
246
        ]);
247
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
248
    }
249
250
    public function testReturnRecoverResultInBeforeEvents()
251
    {

eZ/Publish/Core/Event/Tests/URLServiceTest.php 1 location

@@ 18-45 (lines=28) @@
15
16
class URLServiceTest extends AbstractServiceTest
17
{
18
    public function testUpdateUrlEvents()
19
    {
20
        $traceableEventDispatcher = $this->getEventDispatcher(
21
            BeforeUpdateUrlEvent::class,
22
            UpdateUrlEvent::class
23
        );
24
25
        $parameters = [
26
            $this->createMock(URL::class),
27
            $this->createMock(URLUpdateStruct::class),
28
        ];
29
30
        $updatedUrl = $this->createMock(URL::class);
31
        $innerServiceMock = $this->createMock(URLServiceInterface::class);
32
        $innerServiceMock->method('updateUrl')->willReturn($updatedUrl);
33
34
        $service = new URLService($innerServiceMock, $traceableEventDispatcher);
35
        $result = $service->updateUrl(...$parameters);
36
37
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
38
39
        $this->assertSame($updatedUrl, $result);
40
        $this->assertSame($calledListeners, [
41
            [BeforeUpdateUrlEvent::class, 0],
42
            [UpdateUrlEvent::class, 0],
43
        ]);
44
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
45
    }
46
47
    public function testReturnUpdateUrlResultInBeforeEvents()
48
    {

eZ/Publish/Core/Event/Tests/UserServiceTest.php 4 locations

@@ 41-68 (lines=28) @@
38
39
class UserServiceTest extends AbstractServiceTest
40
{
41
    public function testUpdateUserGroupEvents()
42
    {
43
        $traceableEventDispatcher = $this->getEventDispatcher(
44
            BeforeUpdateUserGroupEvent::class,
45
            UpdateUserGroupEvent::class
46
        );
47
48
        $parameters = [
49
            $this->createMock(UserGroup::class),
50
            $this->createMock(UserGroupUpdateStruct::class),
51
        ];
52
53
        $updatedUserGroup = $this->createMock(UserGroup::class);
54
        $innerServiceMock = $this->createMock(UserServiceInterface::class);
55
        $innerServiceMock->method('updateUserGroup')->willReturn($updatedUserGroup);
56
57
        $service = new UserService($innerServiceMock, $traceableEventDispatcher);
58
        $result = $service->updateUserGroup(...$parameters);
59
60
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
61
62
        $this->assertSame($updatedUserGroup, $result);
63
        $this->assertSame($calledListeners, [
64
            [BeforeUpdateUserGroupEvent::class, 0],
65
            [UpdateUserGroupEvent::class, 0],
66
        ]);
67
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
68
    }
69
70
    public function testReturnUpdateUserGroupResultInBeforeEvents()
71
    {
@@ 143-170 (lines=28) @@
140
        ]);
141
    }
142
143
    public function testUpdateUserEvents()
144
    {
145
        $traceableEventDispatcher = $this->getEventDispatcher(
146
            BeforeUpdateUserEvent::class,
147
            UpdateUserEvent::class
148
        );
149
150
        $parameters = [
151
            $this->createMock(User::class),
152
            $this->createMock(UserUpdateStruct::class),
153
        ];
154
155
        $updatedUser = $this->createMock(User::class);
156
        $innerServiceMock = $this->createMock(UserServiceInterface::class);
157
        $innerServiceMock->method('updateUser')->willReturn($updatedUser);
158
159
        $service = new UserService($innerServiceMock, $traceableEventDispatcher);
160
        $result = $service->updateUser(...$parameters);
161
162
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
163
164
        $this->assertSame($updatedUser, $result);
165
        $this->assertSame($calledListeners, [
166
            [BeforeUpdateUserEvent::class, 0],
167
            [UpdateUserEvent::class, 0],
168
        ]);
169
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
170
    }
171
172
    public function testReturnUpdateUserResultInBeforeEvents()
173
    {
@@ 722-749 (lines=28) @@
719
        ]);
720
    }
721
722
    public function testCreateUserGroupEvents()
723
    {
724
        $traceableEventDispatcher = $this->getEventDispatcher(
725
            BeforeCreateUserGroupEvent::class,
726
            CreateUserGroupEvent::class
727
        );
728
729
        $parameters = [
730
            $this->createMock(UserGroupCreateStruct::class),
731
            $this->createMock(UserGroup::class),
732
        ];
733
734
        $userGroup = $this->createMock(UserGroup::class);
735
        $innerServiceMock = $this->createMock(UserServiceInterface::class);
736
        $innerServiceMock->method('createUserGroup')->willReturn($userGroup);
737
738
        $service = new UserService($innerServiceMock, $traceableEventDispatcher);
739
        $result = $service->createUserGroup(...$parameters);
740
741
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
742
743
        $this->assertSame($userGroup, $result);
744
        $this->assertSame($calledListeners, [
745
            [BeforeCreateUserGroupEvent::class, 0],
746
            [CreateUserGroupEvent::class, 0],
747
        ]);
748
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
749
    }
750
751
    public function testReturnCreateUserGroupResultInBeforeEvents()
752
    {
@@ 824-851 (lines=28) @@
821
        ]);
822
    }
823
824
    public function testUpdateUserTokenEvents()
825
    {
826
        $traceableEventDispatcher = $this->getEventDispatcher(
827
            BeforeUpdateUserTokenEvent::class,
828
            UpdateUserTokenEvent::class
829
        );
830
831
        $parameters = [
832
            $this->createMock(User::class),
833
            $this->createMock(UserTokenUpdateStruct::class),
834
        ];
835
836
        $updatedUser = $this->createMock(User::class);
837
        $innerServiceMock = $this->createMock(UserServiceInterface::class);
838
        $innerServiceMock->method('updateUserToken')->willReturn($updatedUser);
839
840
        $service = new UserService($innerServiceMock, $traceableEventDispatcher);
841
        $result = $service->updateUserToken(...$parameters);
842
843
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
844
845
        $this->assertSame($updatedUser, $result);
846
        $this->assertSame($calledListeners, [
847
            [BeforeUpdateUserTokenEvent::class, 0],
848
            [UpdateUserTokenEvent::class, 0],
849
        ]);
850
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
851
    }
852
853
    public function testReturnUpdateUserTokenResultInBeforeEvents()
854
    {