| @@ 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 | { |
|
| @@ 995-1023 (lines=29) @@ | ||
| 992 | ]); |
|
| 993 | } |
|
| 994 | ||
| 995 | public function testCreateContentDraftEvents() |
|
| 996 | { |
|
| 997 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 998 | BeforeCreateContentDraftEvent::class, |
|
| 999 | CreateContentDraftEvent::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 | [BeforeCreateContentDraftEvent::class, 0], |
|
| 1020 | [CreateContentDraftEvent::class, 0], |
|
| 1021 | ]); |
|
| 1022 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1023 | } |
|
| 1024 | ||
| 1025 | public function testReturnCreateContentDraftResultInBeforeEvents() |
|
| 1026 | { |
|
| @@ 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 | { |
|
| @@ 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 | { |
|
| @@ 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 | { |
|
| @@ 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 | { |
|
| @@ 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 | { |
|
| @@ 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 | { |
|
| @@ 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 | { |
|
| @@ 167-194 (lines=28) @@ | ||
| 164 | ]); |
|
| 165 | } |
|
| 166 | ||
| 167 | public function testUpdateRoleDraftEvents() |
|
| 168 | { |
|
| 169 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 170 | BeforeUpdateRoleDraftEvent::class, |
|
| 171 | UpdateRoleDraftEvent::class |
|
| 172 | ); |
|
| 173 | ||
| 174 | $parameters = [ |
|
| 175 | $this->createMock(RoleDraft::class), |
|
| 176 | $this->createMock(RoleUpdateStruct::class), |
|
| 177 | ]; |
|
| 178 | ||
| 179 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 180 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 181 | $innerServiceMock->method('updateRoleDraft')->willReturn($updatedRoleDraft); |
|
| 182 | ||
| 183 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 184 | $result = $service->updateRoleDraft(...$parameters); |
|
| 185 | ||
| 186 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 187 | ||
| 188 | $this->assertSame($updatedRoleDraft, $result); |
|
| 189 | $this->assertSame($calledListeners, [ |
|
| 190 | [BeforeUpdateRoleDraftEvent::class, 0], |
|
| 191 | [UpdateRoleDraftEvent::class, 0], |
|
| 192 | ]); |
|
| 193 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 194 | } |
|
| 195 | ||
| 196 | public function testReturnUpdateRoleDraftResultInBeforeEvents() |
|
| 197 | { |
|
| @@ 330-358 (lines=29) @@ | ||
| 327 | ]); |
|
| 328 | } |
|
| 329 | ||
| 330 | public function testUpdatePolicyByRoleDraftEvents() |
|
| 331 | { |
|
| 332 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 333 | BeforeUpdatePolicyByRoleDraftEvent::class, |
|
| 334 | UpdatePolicyByRoleDraftEvent::class |
|
| 335 | ); |
|
| 336 | ||
| 337 | $parameters = [ |
|
| 338 | $this->createMock(RoleDraft::class), |
|
| 339 | $this->createMock(PolicyDraft::class), |
|
| 340 | $this->createMock(PolicyUpdateStruct::class), |
|
| 341 | ]; |
|
| 342 | ||
| 343 | $updatedPolicyDraft = $this->createMock(PolicyDraft::class); |
|
| 344 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 345 | $innerServiceMock->method('updatePolicyByRoleDraft')->willReturn($updatedPolicyDraft); |
|
| 346 | ||
| 347 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 348 | $result = $service->updatePolicyByRoleDraft(...$parameters); |
|
| 349 | ||
| 350 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 351 | ||
| 352 | $this->assertSame($updatedPolicyDraft, $result); |
|
| 353 | $this->assertSame($calledListeners, [ |
|
| 354 | [BeforeUpdatePolicyByRoleDraftEvent::class, 0], |
|
| 355 | [UpdatePolicyByRoleDraftEvent::class, 0], |
|
| 356 | ]); |
|
| 357 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 358 | } |
|
| 359 | ||
| 360 | public function testReturnUpdatePolicyByRoleDraftResultInBeforeEvents() |
|
| 361 | { |
|
| @@ 534-561 (lines=28) @@ | ||
| 531 | ]); |
|
| 532 | } |
|
| 533 | ||
| 534 | public function testRemovePolicyByRoleDraftEvents() |
|
| 535 | { |
|
| 536 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 537 | BeforeRemovePolicyByRoleDraftEvent::class, |
|
| 538 | RemovePolicyByRoleDraftEvent::class |
|
| 539 | ); |
|
| 540 | ||
| 541 | $parameters = [ |
|
| 542 | $this->createMock(RoleDraft::class), |
|
| 543 | $this->createMock(PolicyDraft::class), |
|
| 544 | ]; |
|
| 545 | ||
| 546 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 547 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 548 | $innerServiceMock->method('removePolicyByRoleDraft')->willReturn($updatedRoleDraft); |
|
| 549 | ||
| 550 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 551 | $result = $service->removePolicyByRoleDraft(...$parameters); |
|
| 552 | ||
| 553 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 554 | ||
| 555 | $this->assertSame($updatedRoleDraft, $result); |
|
| 556 | $this->assertSame($calledListeners, [ |
|
| 557 | [BeforeRemovePolicyByRoleDraftEvent::class, 0], |
|
| 558 | [RemovePolicyByRoleDraftEvent::class, 0], |
|
| 559 | ]); |
|
| 560 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 561 | } |
|
| 562 | ||
| 563 | public function testReturnRemovePolicyByRoleDraftResultInBeforeEvents() |
|
| 564 | { |
|
| @@ 636-663 (lines=28) @@ | ||
| 633 | ]); |
|
| 634 | } |
|
| 635 | ||
| 636 | public function testAddPolicyByRoleDraftEvents() |
|
| 637 | { |
|
| 638 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 639 | BeforeAddPolicyByRoleDraftEvent::class, |
|
| 640 | AddPolicyByRoleDraftEvent::class |
|
| 641 | ); |
|
| 642 | ||
| 643 | $parameters = [ |
|
| 644 | $this->createMock(RoleDraft::class), |
|
| 645 | $this->createMock(PolicyCreateStruct::class), |
|
| 646 | ]; |
|
| 647 | ||
| 648 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 649 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 650 | $innerServiceMock->method('addPolicyByRoleDraft')->willReturn($updatedRoleDraft); |
|
| 651 | ||
| 652 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 653 | $result = $service->addPolicyByRoleDraft(...$parameters); |
|
| 654 | ||
| 655 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 656 | ||
| 657 | $this->assertSame($updatedRoleDraft, $result); |
|
| 658 | $this->assertSame($calledListeners, [ |
|
| 659 | [BeforeAddPolicyByRoleDraftEvent::class, 0], |
|
| 660 | [AddPolicyByRoleDraftEvent::class, 0], |
|
| 661 | ]); |
|
| 662 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 663 | } |
|
| 664 | ||
| 665 | public function testReturnAddPolicyByRoleDraftResultInBeforeEvents() |
|
| 666 | { |
|