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
            BeforeCopyContentEventInterface::class,
152
            CopyContentEventInterface::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
            [BeforeCopyContentEventInterface::class, 0],
173
            [CopyContentEventInterface::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
            BeforeUpdateContentEventInterface::class,
257
            UpdateContentEventInterface::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
            [BeforeUpdateContentEventInterface::class, 0],
277
            [UpdateContentEventInterface::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
            BeforeAddRelationEventInterface::class,
634
            AddRelationEventInterface::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
            [BeforeAddRelationEventInterface::class, 0],
654
            [AddRelationEventInterface::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
            BeforeUpdateContentMetadataEventInterface::class,
736
            UpdateContentMetadataEventInterface::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
            [BeforeUpdateContentMetadataEventInterface::class, 0],
756
            [UpdateContentMetadataEventInterface::class, 0],
757
        ]);
758
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
759
    }
760
761
    public function testReturnUpdateContentMetadataResultInBeforeEvents()
762
    {
@@ 995-1023 (lines=29) @@
992
        ]);
993
    }
994
995
    public function testCreateContentDraftEvents()
996
    {
997
        $traceableEventDispatcher = $this->getEventDispatcher(
998
            BeforeCreateContentDraftEventInterface::class,
999
            CreateContentDraftEventInterface::class
1000
        );
1001
1002
        $parameters = [
1003
            $this->createMock(ContentInfo::class),
1004
            $this->createMock(VersionInfo::class),
1005
            $this->createMock(User::class),
1006
        ];
1007
1008
        $contentDraft = $this->createMock(Content::class);
1009
        $innerServiceMock = $this->createMock(ContentServiceInterface::class);
1010
        $innerServiceMock->method('createContentDraft')->willReturn($contentDraft);
1011
1012
        $service = new ContentService($innerServiceMock, $traceableEventDispatcher);
1013
        $result = $service->createContentDraft(...$parameters);
1014
1015
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
1016
1017
        $this->assertSame($contentDraft, $result);
1018
        $this->assertSame($calledListeners, [
1019
            [BeforeCreateContentDraftEventInterface::class, 0],
1020
            [CreateContentDraftEventInterface::class, 0],
1021
        ]);
1022
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
1023
    }
1024
1025
    public function testReturnCreateContentDraftResultInBeforeEvents()
1026
    {

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
            BeforeCopyContentTypeEventInterface::class,
1047
            CopyContentTypeEventInterface::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
            [BeforeCopyContentTypeEventInterface::class, 0],
1067
            [CopyContentTypeEventInterface::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
            BeforeCopySubtreeEventInterface::class,
38
            CopySubtreeEventInterface::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
            [BeforeCopySubtreeEventInterface::class, 0],
58
            [CopySubtreeEventInterface::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
            BeforeUpdateLocationEventInterface::class,
513
            UpdateLocationEventInterface::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
            [BeforeUpdateLocationEventInterface::class, 0],
533
            [UpdateLocationEventInterface::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
            BeforeCreateLocationEventInterface::class,
615
            CreateLocationEventInterface::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
            [BeforeCreateLocationEventInterface::class, 0],
635
            [CreateLocationEventInterface::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
            BeforeUpdateObjectStateEventInterface::class,
201
            UpdateObjectStateEventInterface::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
            [BeforeUpdateObjectStateEventInterface::class, 0],
221
            [UpdateObjectStateEventInterface::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
            BeforeCreateObjectStateEventInterface::class,
303
            CreateObjectStateEventInterface::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
            [BeforeCreateObjectStateEventInterface::class, 0],
323
            [CreateObjectStateEventInterface::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
            BeforeUpdateObjectStateGroupEventInterface::class,
405
            UpdateObjectStateGroupEventInterface::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
            [BeforeUpdateObjectStateGroupEventInterface::class, 0],
425
            [UpdateObjectStateGroupEventInterface::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
            BeforeUpdateRoleEventInterface::class,
123
            UpdateRoleEventInterface::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
            [BeforeUpdateRoleEventInterface::class, 0],
143
            [UpdateRoleEventInterface::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
            BeforeAddPolicyEventInterface::class,
343
            AddPolicyEventInterface::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
            [BeforeAddPolicyEventInterface::class, 0],
363
            [AddPolicyEventInterface::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
            BeforeUpdateRoleDraftEventInterface::class,
445
            UpdateRoleDraftEventInterface::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
            [BeforeUpdateRoleDraftEventInterface::class, 0],
465
            [UpdateRoleDraftEventInterface::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
            BeforeUpdatePolicyByRoleDraftEventInterface::class,
667
            UpdatePolicyByRoleDraftEventInterface::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
            [BeforeUpdatePolicyByRoleDraftEventInterface::class, 0],
688
            [UpdatePolicyByRoleDraftEventInterface::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
            BeforeRemovePolicyByRoleDraftEventInterface::class,
871
            RemovePolicyByRoleDraftEventInterface::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
            [BeforeRemovePolicyByRoleDraftEventInterface::class, 0],
891
            [RemovePolicyByRoleDraftEventInterface::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
            BeforeAddPolicyByRoleDraftEventInterface::class,
973
            AddPolicyByRoleDraftEventInterface::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
            [BeforeAddPolicyByRoleDraftEventInterface::class, 0],
993
            [AddPolicyByRoleDraftEventInterface::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
            BeforeUpdatePolicyEventInterface::class,
1345
            UpdatePolicyEventInterface::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
            [BeforeUpdatePolicyEventInterface::class, 0],
1365
            [UpdatePolicyEventInterface::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
            BeforeUpdateSectionEventInterface::class,
92
            UpdateSectionEventInterface::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
            [BeforeUpdateSectionEventInterface::class, 0],
112
            [UpdateSectionEventInterface::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
            BeforeRecoverEventInterface::class,
225
            RecoverEventInterface::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
            [BeforeRecoverEventInterface::class, 0],
245
            [RecoverEventInterface::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
            BeforeUpdateUrlEventInterface::class,
22
            UpdateUrlEventInterface::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
            [BeforeUpdateUrlEventInterface::class, 0],
42
            [UpdateUrlEventInterface::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
            BeforeUpdateUserGroupEventInterface::class,
45
            UpdateUserGroupEventInterface::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
            [BeforeUpdateUserGroupEventInterface::class, 0],
65
            [UpdateUserGroupEventInterface::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
            BeforeUpdateUserEventInterface::class,
147
            UpdateUserEventInterface::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
            [BeforeUpdateUserEventInterface::class, 0],
167
            [UpdateUserEventInterface::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
            BeforeCreateUserGroupEventInterface::class,
726
            CreateUserGroupEventInterface::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
            [BeforeCreateUserGroupEventInterface::class, 0],
746
            [CreateUserGroupEventInterface::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
            BeforeUpdateUserTokenEventInterface::class,
828
            UpdateUserTokenEventInterface::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
            [BeforeUpdateUserTokenEventInterface::class, 0],
848
            [UpdateUserTokenEventInterface::class, 0],
849
        ]);
850
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
851
    }
852
853
    public function testReturnUpdateUserTokenResultInBeforeEvents()
854
    {