| @@ 282-315 (lines=34) @@ | ||
| 279 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 280 | } |
|
| 281 | ||
| 282 | public function testReturnUpdateContentResultInBeforeEvents() |
|
| 283 | { |
|
| 284 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 285 | BeforeUpdateContentEventInterface::class, |
|
| 286 | UpdateContentEventInterface::class |
|
| 287 | ); |
|
| 288 | ||
| 289 | $parameters = [ |
|
| 290 | $this->createMock(VersionInfo::class), |
|
| 291 | $this->createMock(ContentUpdateStruct::class), |
|
| 292 | ]; |
|
| 293 | ||
| 294 | $content = $this->createMock(Content::class); |
|
| 295 | $eventContent = $this->createMock(Content::class); |
|
| 296 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 297 | $innerServiceMock->method('updateContent')->willReturn($content); |
|
| 298 | ||
| 299 | $traceableEventDispatcher->addListener(BeforeUpdateContentEventInterface::class, function (BeforeUpdateContentEventInterface $event) use ($eventContent) { |
|
| 300 | $event->setContent($eventContent); |
|
| 301 | }, 10); |
|
| 302 | ||
| 303 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 304 | $result = $service->updateContent(...$parameters); |
|
| 305 | ||
| 306 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 307 | ||
| 308 | $this->assertSame($eventContent, $result); |
|
| 309 | $this->assertSame($calledListeners, [ |
|
| 310 | [BeforeUpdateContentEventInterface::class, 10], |
|
| 311 | [BeforeUpdateContentEventInterface::class, 0], |
|
| 312 | [UpdateContentEventInterface::class, 0], |
|
| 313 | ]); |
|
| 314 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 315 | } |
|
| 316 | ||
| 317 | public function testUpdateContentStopPropagationInBeforeEvents() |
|
| 318 | { |
|
| @@ 443-476 (lines=34) @@ | ||
| 440 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 441 | } |
|
| 442 | ||
| 443 | public function testReturnCreateContentResultInBeforeEvents() |
|
| 444 | { |
|
| 445 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 446 | BeforeCreateContentEventInterface::class, |
|
| 447 | CreateContentEventInterface::class |
|
| 448 | ); |
|
| 449 | ||
| 450 | $parameters = [ |
|
| 451 | $this->createMock(ContentCreateStruct::class), |
|
| 452 | [], |
|
| 453 | ]; |
|
| 454 | ||
| 455 | $content = $this->createMock(Content::class); |
|
| 456 | $eventContent = $this->createMock(Content::class); |
|
| 457 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 458 | $innerServiceMock->method('createContent')->willReturn($content); |
|
| 459 | ||
| 460 | $traceableEventDispatcher->addListener(BeforeCreateContentEventInterface::class, function (BeforeCreateContentEventInterface $event) use ($eventContent) { |
|
| 461 | $event->setContent($eventContent); |
|
| 462 | }, 10); |
|
| 463 | ||
| 464 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 465 | $result = $service->createContent(...$parameters); |
|
| 466 | ||
| 467 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 468 | ||
| 469 | $this->assertSame($eventContent, $result); |
|
| 470 | $this->assertSame($calledListeners, [ |
|
| 471 | [BeforeCreateContentEventInterface::class, 10], |
|
| 472 | [BeforeCreateContentEventInterface::class, 0], |
|
| 473 | [CreateContentEventInterface::class, 0], |
|
| 474 | ]); |
|
| 475 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 476 | } |
|
| 477 | ||
| 478 | public function testCreateContentStopPropagationInBeforeEvents() |
|
| 479 | { |
|
| @@ 659-692 (lines=34) @@ | ||
| 656 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 657 | } |
|
| 658 | ||
| 659 | public function testReturnAddRelationResultInBeforeEvents() |
|
| 660 | { |
|
| 661 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 662 | BeforeAddRelationEventInterface::class, |
|
| 663 | AddRelationEventInterface::class |
|
| 664 | ); |
|
| 665 | ||
| 666 | $parameters = [ |
|
| 667 | $this->createMock(VersionInfo::class), |
|
| 668 | $this->createMock(ContentInfo::class), |
|
| 669 | ]; |
|
| 670 | ||
| 671 | $relation = $this->createMock(Relation::class); |
|
| 672 | $eventRelation = $this->createMock(Relation::class); |
|
| 673 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 674 | $innerServiceMock->method('addRelation')->willReturn($relation); |
|
| 675 | ||
| 676 | $traceableEventDispatcher->addListener(BeforeAddRelationEventInterface::class, function (BeforeAddRelationEventInterface $event) use ($eventRelation) { |
|
| 677 | $event->setRelation($eventRelation); |
|
| 678 | }, 10); |
|
| 679 | ||
| 680 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 681 | $result = $service->addRelation(...$parameters); |
|
| 682 | ||
| 683 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 684 | ||
| 685 | $this->assertSame($eventRelation, $result); |
|
| 686 | $this->assertSame($calledListeners, [ |
|
| 687 | [BeforeAddRelationEventInterface::class, 10], |
|
| 688 | [BeforeAddRelationEventInterface::class, 0], |
|
| 689 | [AddRelationEventInterface::class, 0], |
|
| 690 | ]); |
|
| 691 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 692 | } |
|
| 693 | ||
| 694 | public function testAddRelationStopPropagationInBeforeEvents() |
|
| 695 | { |
|
| @@ 761-794 (lines=34) @@ | ||
| 758 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 759 | } |
|
| 760 | ||
| 761 | public function testReturnUpdateContentMetadataResultInBeforeEvents() |
|
| 762 | { |
|
| 763 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 764 | BeforeUpdateContentMetadataEventInterface::class, |
|
| 765 | UpdateContentMetadataEventInterface::class |
|
| 766 | ); |
|
| 767 | ||
| 768 | $parameters = [ |
|
| 769 | $this->createMock(ContentInfo::class), |
|
| 770 | $this->createMock(ContentMetadataUpdateStruct::class), |
|
| 771 | ]; |
|
| 772 | ||
| 773 | $content = $this->createMock(Content::class); |
|
| 774 | $eventContent = $this->createMock(Content::class); |
|
| 775 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 776 | $innerServiceMock->method('updateContentMetadata')->willReturn($content); |
|
| 777 | ||
| 778 | $traceableEventDispatcher->addListener(BeforeUpdateContentMetadataEventInterface::class, function (BeforeUpdateContentMetadataEventInterface $event) use ($eventContent) { |
|
| 779 | $event->setContent($eventContent); |
|
| 780 | }, 10); |
|
| 781 | ||
| 782 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 783 | $result = $service->updateContentMetadata(...$parameters); |
|
| 784 | ||
| 785 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 786 | ||
| 787 | $this->assertSame($eventContent, $result); |
|
| 788 | $this->assertSame($calledListeners, [ |
|
| 789 | [BeforeUpdateContentMetadataEventInterface::class, 10], |
|
| 790 | [BeforeUpdateContentMetadataEventInterface::class, 0], |
|
| 791 | [UpdateContentMetadataEventInterface::class, 0], |
|
| 792 | ]); |
|
| 793 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 794 | } |
|
| 795 | ||
| 796 | public function testUpdateContentMetadataStopPropagationInBeforeEvents() |
|
| 797 | { |
|
| @@ 922-955 (lines=34) @@ | ||
| 919 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 920 | } |
|
| 921 | ||
| 922 | public function testReturnPublishVersionResultInBeforeEvents() |
|
| 923 | { |
|
| 924 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 925 | BeforePublishVersionEventInterface::class, |
|
| 926 | PublishVersionEventInterface::class |
|
| 927 | ); |
|
| 928 | ||
| 929 | $parameters = [ |
|
| 930 | $this->createMock(VersionInfo::class), |
|
| 931 | [], |
|
| 932 | ]; |
|
| 933 | ||
| 934 | $content = $this->createMock(Content::class); |
|
| 935 | $eventContent = $this->createMock(Content::class); |
|
| 936 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 937 | $innerServiceMock->method('publishVersion')->willReturn($content); |
|
| 938 | ||
| 939 | $traceableEventDispatcher->addListener(BeforePublishVersionEventInterface::class, function (BeforePublishVersionEventInterface $event) use ($eventContent) { |
|
| 940 | $event->setContent($eventContent); |
|
| 941 | }, 10); |
|
| 942 | ||
| 943 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 944 | $result = $service->publishVersion(...$parameters); |
|
| 945 | ||
| 946 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 947 | ||
| 948 | $this->assertSame($eventContent, $result); |
|
| 949 | $this->assertSame($calledListeners, [ |
|
| 950 | [BeforePublishVersionEventInterface::class, 10], |
|
| 951 | [BeforePublishVersionEventInterface::class, 0], |
|
| 952 | [PublishVersionEventInterface::class, 0], |
|
| 953 | ]); |
|
| 954 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 955 | } |
|
| 956 | ||
| 957 | public function testPublishVersionStopPropagationInBeforeEvents() |
|
| 958 | { |
|
| @@ 199-231 (lines=33) @@ | ||
| 196 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 197 | } |
|
| 198 | ||
| 199 | public function testReturnCreateContentTypeDraftResultInBeforeEvents() |
|
| 200 | { |
|
| 201 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 202 | BeforeCreateContentTypeDraftEventInterface::class, |
|
| 203 | CreateContentTypeDraftEventInterface::class |
|
| 204 | ); |
|
| 205 | ||
| 206 | $parameters = [ |
|
| 207 | $this->createMock(ContentType::class), |
|
| 208 | ]; |
|
| 209 | ||
| 210 | $contentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 211 | $eventContentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 212 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 213 | $innerServiceMock->method('createContentTypeDraft')->willReturn($contentTypeDraft); |
|
| 214 | ||
| 215 | $traceableEventDispatcher->addListener(BeforeCreateContentTypeDraftEventInterface::class, function (BeforeCreateContentTypeDraftEventInterface $event) use ($eventContentTypeDraft) { |
|
| 216 | $event->setContentTypeDraft($eventContentTypeDraft); |
|
| 217 | }, 10); |
|
| 218 | ||
| 219 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 220 | $result = $service->createContentTypeDraft(...$parameters); |
|
| 221 | ||
| 222 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 223 | ||
| 224 | $this->assertSame($eventContentTypeDraft, $result); |
|
| 225 | $this->assertSame($calledListeners, [ |
|
| 226 | [BeforeCreateContentTypeDraftEventInterface::class, 10], |
|
| 227 | [BeforeCreateContentTypeDraftEventInterface::class, 0], |
|
| 228 | [CreateContentTypeDraftEventInterface::class, 0], |
|
| 229 | ]); |
|
| 230 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 231 | } |
|
| 232 | ||
| 233 | public function testCreateContentTypeDraftStopPropagationInBeforeEvents() |
|
| 234 | { |
|
| @@ 298-330 (lines=33) @@ | ||
| 295 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 296 | } |
|
| 297 | ||
| 298 | public function testReturnCreateContentTypeGroupResultInBeforeEvents() |
|
| 299 | { |
|
| 300 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 301 | BeforeCreateContentTypeGroupEventInterface::class, |
|
| 302 | CreateContentTypeGroupEventInterface::class |
|
| 303 | ); |
|
| 304 | ||
| 305 | $parameters = [ |
|
| 306 | $this->createMock(ContentTypeGroupCreateStruct::class), |
|
| 307 | ]; |
|
| 308 | ||
| 309 | $contentTypeGroup = $this->createMock(ContentTypeGroup::class); |
|
| 310 | $eventContentTypeGroup = $this->createMock(ContentTypeGroup::class); |
|
| 311 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 312 | $innerServiceMock->method('createContentTypeGroup')->willReturn($contentTypeGroup); |
|
| 313 | ||
| 314 | $traceableEventDispatcher->addListener(BeforeCreateContentTypeGroupEventInterface::class, function (BeforeCreateContentTypeGroupEventInterface $event) use ($eventContentTypeGroup) { |
|
| 315 | $event->setContentTypeGroup($eventContentTypeGroup); |
|
| 316 | }, 10); |
|
| 317 | ||
| 318 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 319 | $result = $service->createContentTypeGroup(...$parameters); |
|
| 320 | ||
| 321 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 322 | ||
| 323 | $this->assertSame($eventContentTypeGroup, $result); |
|
| 324 | $this->assertSame($calledListeners, [ |
|
| 325 | [BeforeCreateContentTypeGroupEventInterface::class, 10], |
|
| 326 | [BeforeCreateContentTypeGroupEventInterface::class, 0], |
|
| 327 | [CreateContentTypeGroupEventInterface::class, 0], |
|
| 328 | ]); |
|
| 329 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 330 | } |
|
| 331 | ||
| 332 | public function testCreateContentTypeGroupStopPropagationInBeforeEvents() |
|
| 333 | { |
|
| @@ 457-490 (lines=34) @@ | ||
| 454 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 455 | } |
|
| 456 | ||
| 457 | public function testReturnCreateContentTypeResultInBeforeEvents() |
|
| 458 | { |
|
| 459 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 460 | BeforeCreateContentTypeEventInterface::class, |
|
| 461 | CreateContentTypeEventInterface::class |
|
| 462 | ); |
|
| 463 | ||
| 464 | $parameters = [ |
|
| 465 | $this->createMock(ContentTypeCreateStruct::class), |
|
| 466 | [], |
|
| 467 | ]; |
|
| 468 | ||
| 469 | $contentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 470 | $eventContentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 471 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 472 | $innerServiceMock->method('createContentType')->willReturn($contentTypeDraft); |
|
| 473 | ||
| 474 | $traceableEventDispatcher->addListener(BeforeCreateContentTypeEventInterface::class, function (BeforeCreateContentTypeEventInterface $event) use ($eventContentTypeDraft) { |
|
| 475 | $event->setContentTypeDraft($eventContentTypeDraft); |
|
| 476 | }, 10); |
|
| 477 | ||
| 478 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 479 | $result = $service->createContentType(...$parameters); |
|
| 480 | ||
| 481 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 482 | ||
| 483 | $this->assertSame($eventContentTypeDraft, $result); |
|
| 484 | $this->assertSame($calledListeners, [ |
|
| 485 | [BeforeCreateContentTypeEventInterface::class, 10], |
|
| 486 | [BeforeCreateContentTypeEventInterface::class, 0], |
|
| 487 | [CreateContentTypeEventInterface::class, 0], |
|
| 488 | ]); |
|
| 489 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 490 | } |
|
| 491 | ||
| 492 | public function testCreateContentTypeStopPropagationInBeforeEvents() |
|
| 493 | { |
|
| @@ 559-592 (lines=34) @@ | ||
| 556 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 557 | } |
|
| 558 | ||
| 559 | public function testReturnRemoveContentTypeTranslationResultInBeforeEvents() |
|
| 560 | { |
|
| 561 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 562 | BeforeRemoveContentTypeTranslationEventInterface::class, |
|
| 563 | RemoveContentTypeTranslationEventInterface::class |
|
| 564 | ); |
|
| 565 | ||
| 566 | $parameters = [ |
|
| 567 | $this->createMock(ContentTypeDraft::class), |
|
| 568 | 'random_value_5cff79c318f913.11826610', |
|
| 569 | ]; |
|
| 570 | ||
| 571 | $newContentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 572 | $eventNewContentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 573 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 574 | $innerServiceMock->method('removeContentTypeTranslation')->willReturn($newContentTypeDraft); |
|
| 575 | ||
| 576 | $traceableEventDispatcher->addListener(BeforeRemoveContentTypeTranslationEventInterface::class, function (BeforeRemoveContentTypeTranslationEventInterface $event) use ($eventNewContentTypeDraft) { |
|
| 577 | $event->setNewContentTypeDraft($eventNewContentTypeDraft); |
|
| 578 | }, 10); |
|
| 579 | ||
| 580 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 581 | $result = $service->removeContentTypeTranslation(...$parameters); |
|
| 582 | ||
| 583 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 584 | ||
| 585 | $this->assertSame($eventNewContentTypeDraft, $result); |
|
| 586 | $this->assertSame($calledListeners, [ |
|
| 587 | [BeforeRemoveContentTypeTranslationEventInterface::class, 10], |
|
| 588 | [BeforeRemoveContentTypeTranslationEventInterface::class, 0], |
|
| 589 | [RemoveContentTypeTranslationEventInterface::class, 0], |
|
| 590 | ]); |
|
| 591 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 592 | } |
|
| 593 | ||
| 594 | public function testRemoveContentTypeTranslationStopPropagationInBeforeEvents() |
|
| 595 | { |
|
| @@ 1072-1105 (lines=34) @@ | ||
| 1069 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1070 | } |
|
| 1071 | ||
| 1072 | public function testReturnCopyContentTypeResultInBeforeEvents() |
|
| 1073 | { |
|
| 1074 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1075 | BeforeCopyContentTypeEventInterface::class, |
|
| 1076 | CopyContentTypeEventInterface::class |
|
| 1077 | ); |
|
| 1078 | ||
| 1079 | $parameters = [ |
|
| 1080 | $this->createMock(ContentType::class), |
|
| 1081 | $this->createMock(User::class), |
|
| 1082 | ]; |
|
| 1083 | ||
| 1084 | $contentTypeCopy = $this->createMock(ContentType::class); |
|
| 1085 | $eventContentTypeCopy = $this->createMock(ContentType::class); |
|
| 1086 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 1087 | $innerServiceMock->method('copyContentType')->willReturn($contentTypeCopy); |
|
| 1088 | ||
| 1089 | $traceableEventDispatcher->addListener(BeforeCopyContentTypeEventInterface::class, function (BeforeCopyContentTypeEventInterface $event) use ($eventContentTypeCopy) { |
|
| 1090 | $event->setContentTypeCopy($eventContentTypeCopy); |
|
| 1091 | }, 10); |
|
| 1092 | ||
| 1093 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 1094 | $result = $service->copyContentType(...$parameters); |
|
| 1095 | ||
| 1096 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1097 | ||
| 1098 | $this->assertSame($eventContentTypeCopy, $result); |
|
| 1099 | $this->assertSame($calledListeners, [ |
|
| 1100 | [BeforeCopyContentTypeEventInterface::class, 10], |
|
| 1101 | [BeforeCopyContentTypeEventInterface::class, 0], |
|
| 1102 | [CopyContentTypeEventInterface::class, 0], |
|
| 1103 | ]); |
|
| 1104 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1105 | } |
|
| 1106 | ||
| 1107 | public function testCopyContentTypeStopPropagationInBeforeEvents() |
|
| 1108 | { |
|
| @@ 111-143 (lines=33) @@ | ||
| 108 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 109 | } |
|
| 110 | ||
| 111 | public function testReturnCreateLanguageResultInBeforeEvents() |
|
| 112 | { |
|
| 113 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 114 | BeforeCreateLanguageEventInterface::class, |
|
| 115 | CreateLanguageEventInterface::class |
|
| 116 | ); |
|
| 117 | ||
| 118 | $parameters = [ |
|
| 119 | $this->createMock(LanguageCreateStruct::class), |
|
| 120 | ]; |
|
| 121 | ||
| 122 | $language = $this->createMock(Language::class); |
|
| 123 | $eventLanguage = $this->createMock(Language::class); |
|
| 124 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 125 | $innerServiceMock->method('createLanguage')->willReturn($language); |
|
| 126 | ||
| 127 | $traceableEventDispatcher->addListener(BeforeCreateLanguageEventInterface::class, function (BeforeCreateLanguageEventInterface $event) use ($eventLanguage) { |
|
| 128 | $event->setLanguage($eventLanguage); |
|
| 129 | }, 10); |
|
| 130 | ||
| 131 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 132 | $result = $service->createLanguage(...$parameters); |
|
| 133 | ||
| 134 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 135 | ||
| 136 | $this->assertSame($eventLanguage, $result); |
|
| 137 | $this->assertSame($calledListeners, [ |
|
| 138 | [BeforeCreateLanguageEventInterface::class, 10], |
|
| 139 | [BeforeCreateLanguageEventInterface::class, 0], |
|
| 140 | [CreateLanguageEventInterface::class, 0], |
|
| 141 | ]); |
|
| 142 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 143 | } |
|
| 144 | ||
| 145 | public function testCreateLanguageStopPropagationInBeforeEvents() |
|
| 146 | { |
|
| @@ 211-244 (lines=34) @@ | ||
| 208 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 209 | } |
|
| 210 | ||
| 211 | public function testReturnUpdateLanguageNameResultInBeforeEvents() |
|
| 212 | { |
|
| 213 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 214 | BeforeUpdateLanguageNameEventInterface::class, |
|
| 215 | UpdateLanguageNameEventInterface::class |
|
| 216 | ); |
|
| 217 | ||
| 218 | $parameters = [ |
|
| 219 | $this->createMock(Language::class), |
|
| 220 | 'random_value_5cff79c3161312.94068030', |
|
| 221 | ]; |
|
| 222 | ||
| 223 | $updatedLanguage = $this->createMock(Language::class); |
|
| 224 | $eventUpdatedLanguage = $this->createMock(Language::class); |
|
| 225 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 226 | $innerServiceMock->method('updateLanguageName')->willReturn($updatedLanguage); |
|
| 227 | ||
| 228 | $traceableEventDispatcher->addListener(BeforeUpdateLanguageNameEventInterface::class, function (BeforeUpdateLanguageNameEventInterface $event) use ($eventUpdatedLanguage) { |
|
| 229 | $event->setUpdatedLanguage($eventUpdatedLanguage); |
|
| 230 | }, 10); |
|
| 231 | ||
| 232 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 233 | $result = $service->updateLanguageName(...$parameters); |
|
| 234 | ||
| 235 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 236 | ||
| 237 | $this->assertSame($eventUpdatedLanguage, $result); |
|
| 238 | $this->assertSame($calledListeners, [ |
|
| 239 | [BeforeUpdateLanguageNameEventInterface::class, 10], |
|
| 240 | [BeforeUpdateLanguageNameEventInterface::class, 0], |
|
| 241 | [UpdateLanguageNameEventInterface::class, 0], |
|
| 242 | ]); |
|
| 243 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 244 | } |
|
| 245 | ||
| 246 | public function testUpdateLanguageNameStopPropagationInBeforeEvents() |
|
| 247 | { |
|
| @@ 312-344 (lines=33) @@ | ||
| 309 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 310 | } |
|
| 311 | ||
| 312 | public function testReturnDisableLanguageResultInBeforeEvents() |
|
| 313 | { |
|
| 314 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 315 | BeforeDisableLanguageEventInterface::class, |
|
| 316 | DisableLanguageEventInterface::class |
|
| 317 | ); |
|
| 318 | ||
| 319 | $parameters = [ |
|
| 320 | $this->createMock(Language::class), |
|
| 321 | ]; |
|
| 322 | ||
| 323 | $disabledLanguage = $this->createMock(Language::class); |
|
| 324 | $eventDisabledLanguage = $this->createMock(Language::class); |
|
| 325 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 326 | $innerServiceMock->method('disableLanguage')->willReturn($disabledLanguage); |
|
| 327 | ||
| 328 | $traceableEventDispatcher->addListener(BeforeDisableLanguageEventInterface::class, function (BeforeDisableLanguageEventInterface $event) use ($eventDisabledLanguage) { |
|
| 329 | $event->setDisabledLanguage($eventDisabledLanguage); |
|
| 330 | }, 10); |
|
| 331 | ||
| 332 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 333 | $result = $service->disableLanguage(...$parameters); |
|
| 334 | ||
| 335 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 336 | ||
| 337 | $this->assertSame($eventDisabledLanguage, $result); |
|
| 338 | $this->assertSame($calledListeners, [ |
|
| 339 | [BeforeDisableLanguageEventInterface::class, 10], |
|
| 340 | [BeforeDisableLanguageEventInterface::class, 0], |
|
| 341 | [DisableLanguageEventInterface::class, 0], |
|
| 342 | ]); |
|
| 343 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 344 | } |
|
| 345 | ||
| 346 | public function testDisableLanguageStopPropagationInBeforeEvents() |
|
| 347 | { |
|
| @@ 411-443 (lines=33) @@ | ||
| 408 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 409 | } |
|
| 410 | ||
| 411 | public function testReturnEnableLanguageResultInBeforeEvents() |
|
| 412 | { |
|
| 413 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 414 | BeforeEnableLanguageEventInterface::class, |
|
| 415 | EnableLanguageEventInterface::class |
|
| 416 | ); |
|
| 417 | ||
| 418 | $parameters = [ |
|
| 419 | $this->createMock(Language::class), |
|
| 420 | ]; |
|
| 421 | ||
| 422 | $enabledLanguage = $this->createMock(Language::class); |
|
| 423 | $eventEnabledLanguage = $this->createMock(Language::class); |
|
| 424 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 425 | $innerServiceMock->method('enableLanguage')->willReturn($enabledLanguage); |
|
| 426 | ||
| 427 | $traceableEventDispatcher->addListener(BeforeEnableLanguageEventInterface::class, function (BeforeEnableLanguageEventInterface $event) use ($eventEnabledLanguage) { |
|
| 428 | $event->setEnabledLanguage($eventEnabledLanguage); |
|
| 429 | }, 10); |
|
| 430 | ||
| 431 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 432 | $result = $service->enableLanguage(...$parameters); |
|
| 433 | ||
| 434 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 435 | ||
| 436 | $this->assertSame($eventEnabledLanguage, $result); |
|
| 437 | $this->assertSame($calledListeners, [ |
|
| 438 | [BeforeEnableLanguageEventInterface::class, 10], |
|
| 439 | [BeforeEnableLanguageEventInterface::class, 0], |
|
| 440 | [EnableLanguageEventInterface::class, 0], |
|
| 441 | ]); |
|
| 442 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 443 | } |
|
| 444 | ||
| 445 | public function testEnableLanguageStopPropagationInBeforeEvents() |
|
| 446 | { |
|
| @@ 63-96 (lines=34) @@ | ||
| 60 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 61 | } |
|
| 62 | ||
| 63 | public function testReturnCopySubtreeResultInBeforeEvents() |
|
| 64 | { |
|
| 65 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 66 | BeforeCopySubtreeEventInterface::class, |
|
| 67 | CopySubtreeEventInterface::class |
|
| 68 | ); |
|
| 69 | ||
| 70 | $parameters = [ |
|
| 71 | $this->createMock(Location::class), |
|
| 72 | $this->createMock(Location::class), |
|
| 73 | ]; |
|
| 74 | ||
| 75 | $location = $this->createMock(Location::class); |
|
| 76 | $eventLocation = $this->createMock(Location::class); |
|
| 77 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 78 | $innerServiceMock->method('copySubtree')->willReturn($location); |
|
| 79 | ||
| 80 | $traceableEventDispatcher->addListener(BeforeCopySubtreeEventInterface::class, function (BeforeCopySubtreeEventInterface $event) use ($eventLocation) { |
|
| 81 | $event->setLocation($eventLocation); |
|
| 82 | }, 10); |
|
| 83 | ||
| 84 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 85 | $result = $service->copySubtree(...$parameters); |
|
| 86 | ||
| 87 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 88 | ||
| 89 | $this->assertSame($eventLocation, $result); |
|
| 90 | $this->assertSame($calledListeners, [ |
|
| 91 | [BeforeCopySubtreeEventInterface::class, 10], |
|
| 92 | [BeforeCopySubtreeEventInterface::class, 0], |
|
| 93 | [CopySubtreeEventInterface::class, 0], |
|
| 94 | ]); |
|
| 95 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 96 | } |
|
| 97 | ||
| 98 | public function testCopySubtreeStopPropagationInBeforeEvents() |
|
| 99 | { |
|
| @@ 221-253 (lines=33) @@ | ||
| 218 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 219 | } |
|
| 220 | ||
| 221 | public function testReturnUnhideLocationResultInBeforeEvents() |
|
| 222 | { |
|
| 223 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 224 | BeforeUnhideLocationEventInterface::class, |
|
| 225 | UnhideLocationEventInterface::class |
|
| 226 | ); |
|
| 227 | ||
| 228 | $parameters = [ |
|
| 229 | $this->createMock(Location::class), |
|
| 230 | ]; |
|
| 231 | ||
| 232 | $revealedLocation = $this->createMock(Location::class); |
|
| 233 | $eventRevealedLocation = $this->createMock(Location::class); |
|
| 234 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 235 | $innerServiceMock->method('unhideLocation')->willReturn($revealedLocation); |
|
| 236 | ||
| 237 | $traceableEventDispatcher->addListener(BeforeUnhideLocationEventInterface::class, function (BeforeUnhideLocationEventInterface $event) use ($eventRevealedLocation) { |
|
| 238 | $event->setRevealedLocation($eventRevealedLocation); |
|
| 239 | }, 10); |
|
| 240 | ||
| 241 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 242 | $result = $service->unhideLocation(...$parameters); |
|
| 243 | ||
| 244 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 245 | ||
| 246 | $this->assertSame($eventRevealedLocation, $result); |
|
| 247 | $this->assertSame($calledListeners, [ |
|
| 248 | [BeforeUnhideLocationEventInterface::class, 10], |
|
| 249 | [BeforeUnhideLocationEventInterface::class, 0], |
|
| 250 | [UnhideLocationEventInterface::class, 0], |
|
| 251 | ]); |
|
| 252 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 253 | } |
|
| 254 | ||
| 255 | public function testUnhideLocationStopPropagationInBeforeEvents() |
|
| 256 | { |
|
| @@ 320-352 (lines=33) @@ | ||
| 317 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 318 | } |
|
| 319 | ||
| 320 | public function testReturnHideLocationResultInBeforeEvents() |
|
| 321 | { |
|
| 322 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 323 | BeforeHideLocationEventInterface::class, |
|
| 324 | HideLocationEventInterface::class |
|
| 325 | ); |
|
| 326 | ||
| 327 | $parameters = [ |
|
| 328 | $this->createMock(Location::class), |
|
| 329 | ]; |
|
| 330 | ||
| 331 | $hiddenLocation = $this->createMock(Location::class); |
|
| 332 | $eventHiddenLocation = $this->createMock(Location::class); |
|
| 333 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 334 | $innerServiceMock->method('hideLocation')->willReturn($hiddenLocation); |
|
| 335 | ||
| 336 | $traceableEventDispatcher->addListener(BeforeHideLocationEventInterface::class, function (BeforeHideLocationEventInterface $event) use ($eventHiddenLocation) { |
|
| 337 | $event->setHiddenLocation($eventHiddenLocation); |
|
| 338 | }, 10); |
|
| 339 | ||
| 340 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 341 | $result = $service->hideLocation(...$parameters); |
|
| 342 | ||
| 343 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 344 | ||
| 345 | $this->assertSame($eventHiddenLocation, $result); |
|
| 346 | $this->assertSame($calledListeners, [ |
|
| 347 | [BeforeHideLocationEventInterface::class, 10], |
|
| 348 | [BeforeHideLocationEventInterface::class, 0], |
|
| 349 | [HideLocationEventInterface::class, 0], |
|
| 350 | ]); |
|
| 351 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 352 | } |
|
| 353 | ||
| 354 | public function testHideLocationStopPropagationInBeforeEvents() |
|
| 355 | { |
|
| @@ 538-571 (lines=34) @@ | ||
| 535 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 536 | } |
|
| 537 | ||
| 538 | public function testReturnUpdateLocationResultInBeforeEvents() |
|
| 539 | { |
|
| 540 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 541 | BeforeUpdateLocationEventInterface::class, |
|
| 542 | UpdateLocationEventInterface::class |
|
| 543 | ); |
|
| 544 | ||
| 545 | $parameters = [ |
|
| 546 | $this->createMock(Location::class), |
|
| 547 | $this->createMock(LocationUpdateStruct::class), |
|
| 548 | ]; |
|
| 549 | ||
| 550 | $updatedLocation = $this->createMock(Location::class); |
|
| 551 | $eventUpdatedLocation = $this->createMock(Location::class); |
|
| 552 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 553 | $innerServiceMock->method('updateLocation')->willReturn($updatedLocation); |
|
| 554 | ||
| 555 | $traceableEventDispatcher->addListener(BeforeUpdateLocationEventInterface::class, function (BeforeUpdateLocationEventInterface $event) use ($eventUpdatedLocation) { |
|
| 556 | $event->setUpdatedLocation($eventUpdatedLocation); |
|
| 557 | }, 10); |
|
| 558 | ||
| 559 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 560 | $result = $service->updateLocation(...$parameters); |
|
| 561 | ||
| 562 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 563 | ||
| 564 | $this->assertSame($eventUpdatedLocation, $result); |
|
| 565 | $this->assertSame($calledListeners, [ |
|
| 566 | [BeforeUpdateLocationEventInterface::class, 10], |
|
| 567 | [BeforeUpdateLocationEventInterface::class, 0], |
|
| 568 | [UpdateLocationEventInterface::class, 0], |
|
| 569 | ]); |
|
| 570 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 571 | } |
|
| 572 | ||
| 573 | public function testUpdateLocationStopPropagationInBeforeEvents() |
|
| 574 | { |
|
| @@ 640-673 (lines=34) @@ | ||
| 637 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 638 | } |
|
| 639 | ||
| 640 | public function testReturnCreateLocationResultInBeforeEvents() |
|
| 641 | { |
|
| 642 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 643 | BeforeCreateLocationEventInterface::class, |
|
| 644 | CreateLocationEventInterface::class |
|
| 645 | ); |
|
| 646 | ||
| 647 | $parameters = [ |
|
| 648 | $this->createMock(ContentInfo::class), |
|
| 649 | $this->createMock(LocationCreateStruct::class), |
|
| 650 | ]; |
|
| 651 | ||
| 652 | $location = $this->createMock(Location::class); |
|
| 653 | $eventLocation = $this->createMock(Location::class); |
|
| 654 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 655 | $innerServiceMock->method('createLocation')->willReturn($location); |
|
| 656 | ||
| 657 | $traceableEventDispatcher->addListener(BeforeCreateLocationEventInterface::class, function (BeforeCreateLocationEventInterface $event) use ($eventLocation) { |
|
| 658 | $event->setLocation($eventLocation); |
|
| 659 | }, 10); |
|
| 660 | ||
| 661 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 662 | $result = $service->createLocation(...$parameters); |
|
| 663 | ||
| 664 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 665 | ||
| 666 | $this->assertSame($eventLocation, $result); |
|
| 667 | $this->assertSame($calledListeners, [ |
|
| 668 | [BeforeCreateLocationEventInterface::class, 10], |
|
| 669 | [BeforeCreateLocationEventInterface::class, 0], |
|
| 670 | [CreateLocationEventInterface::class, 0], |
|
| 671 | ]); |
|
| 672 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 673 | } |
|
| 674 | ||
| 675 | public function testCreateLocationStopPropagationInBeforeEvents() |
|
| 676 | { |
|
| @@ 50-82 (lines=33) @@ | ||
| 47 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 48 | } |
|
| 49 | ||
| 50 | public function testReturnCreateNotificationResultInBeforeEvents() |
|
| 51 | { |
|
| 52 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 53 | BeforeCreateNotificationEventInterface::class, |
|
| 54 | CreateNotificationEventInterface::class |
|
| 55 | ); |
|
| 56 | ||
| 57 | $parameters = [ |
|
| 58 | $this->createMock(CreateStruct::class), |
|
| 59 | ]; |
|
| 60 | ||
| 61 | $notification = $this->createMock(Notification::class); |
|
| 62 | $eventNotification = $this->createMock(Notification::class); |
|
| 63 | $innerServiceMock = $this->createMock(NotificationServiceInterface::class); |
|
| 64 | $innerServiceMock->method('createNotification')->willReturn($notification); |
|
| 65 | ||
| 66 | $traceableEventDispatcher->addListener(BeforeCreateNotificationEventInterface::class, function (BeforeCreateNotificationEventInterface $event) use ($eventNotification) { |
|
| 67 | $event->setNotification($eventNotification); |
|
| 68 | }, 10); |
|
| 69 | ||
| 70 | $service = new NotificationService($innerServiceMock, $traceableEventDispatcher); |
|
| 71 | $result = $service->createNotification(...$parameters); |
|
| 72 | ||
| 73 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 74 | ||
| 75 | $this->assertSame($eventNotification, $result); |
|
| 76 | $this->assertSame($calledListeners, [ |
|
| 77 | [BeforeCreateNotificationEventInterface::class, 10], |
|
| 78 | [BeforeCreateNotificationEventInterface::class, 0], |
|
| 79 | [CreateNotificationEventInterface::class, 0], |
|
| 80 | ]); |
|
| 81 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 82 | } |
|
| 83 | ||
| 84 | public function testCreateNotificationStopPropagationInBeforeEvents() |
|
| 85 | { |
|
| @@ 126-158 (lines=33) @@ | ||
| 123 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function testReturnCreateObjectStateGroupResultInBeforeEvents() |
|
| 127 | { |
|
| 128 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 129 | BeforeCreateObjectStateGroupEventInterface::class, |
|
| 130 | CreateObjectStateGroupEventInterface::class |
|
| 131 | ); |
|
| 132 | ||
| 133 | $parameters = [ |
|
| 134 | $this->createMock(ObjectStateGroupCreateStruct::class), |
|
| 135 | ]; |
|
| 136 | ||
| 137 | $objectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 138 | $eventObjectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 139 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 140 | $innerServiceMock->method('createObjectStateGroup')->willReturn($objectStateGroup); |
|
| 141 | ||
| 142 | $traceableEventDispatcher->addListener(BeforeCreateObjectStateGroupEventInterface::class, function (BeforeCreateObjectStateGroupEventInterface $event) use ($eventObjectStateGroup) { |
|
| 143 | $event->setObjectStateGroup($eventObjectStateGroup); |
|
| 144 | }, 10); |
|
| 145 | ||
| 146 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 147 | $result = $service->createObjectStateGroup(...$parameters); |
|
| 148 | ||
| 149 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 150 | ||
| 151 | $this->assertSame($eventObjectStateGroup, $result); |
|
| 152 | $this->assertSame($calledListeners, [ |
|
| 153 | [BeforeCreateObjectStateGroupEventInterface::class, 10], |
|
| 154 | [BeforeCreateObjectStateGroupEventInterface::class, 0], |
|
| 155 | [CreateObjectStateGroupEventInterface::class, 0], |
|
| 156 | ]); |
|
| 157 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 158 | } |
|
| 159 | ||
| 160 | public function testCreateObjectStateGroupStopPropagationInBeforeEvents() |
|
| 161 | { |
|
| @@ 226-259 (lines=34) @@ | ||
| 223 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 224 | } |
|
| 225 | ||
| 226 | public function testReturnUpdateObjectStateResultInBeforeEvents() |
|
| 227 | { |
|
| 228 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 229 | BeforeUpdateObjectStateEventInterface::class, |
|
| 230 | UpdateObjectStateEventInterface::class |
|
| 231 | ); |
|
| 232 | ||
| 233 | $parameters = [ |
|
| 234 | $this->createMock(ObjectState::class), |
|
| 235 | $this->createMock(ObjectStateUpdateStruct::class), |
|
| 236 | ]; |
|
| 237 | ||
| 238 | $updatedObjectState = $this->createMock(ObjectState::class); |
|
| 239 | $eventUpdatedObjectState = $this->createMock(ObjectState::class); |
|
| 240 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 241 | $innerServiceMock->method('updateObjectState')->willReturn($updatedObjectState); |
|
| 242 | ||
| 243 | $traceableEventDispatcher->addListener(BeforeUpdateObjectStateEventInterface::class, function (BeforeUpdateObjectStateEventInterface $event) use ($eventUpdatedObjectState) { |
|
| 244 | $event->setUpdatedObjectState($eventUpdatedObjectState); |
|
| 245 | }, 10); |
|
| 246 | ||
| 247 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 248 | $result = $service->updateObjectState(...$parameters); |
|
| 249 | ||
| 250 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 251 | ||
| 252 | $this->assertSame($eventUpdatedObjectState, $result); |
|
| 253 | $this->assertSame($calledListeners, [ |
|
| 254 | [BeforeUpdateObjectStateEventInterface::class, 10], |
|
| 255 | [BeforeUpdateObjectStateEventInterface::class, 0], |
|
| 256 | [UpdateObjectStateEventInterface::class, 0], |
|
| 257 | ]); |
|
| 258 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 259 | } |
|
| 260 | ||
| 261 | public function testUpdateObjectStateStopPropagationInBeforeEvents() |
|
| 262 | { |
|
| @@ 328-361 (lines=34) @@ | ||
| 325 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 326 | } |
|
| 327 | ||
| 328 | public function testReturnCreateObjectStateResultInBeforeEvents() |
|
| 329 | { |
|
| 330 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 331 | BeforeCreateObjectStateEventInterface::class, |
|
| 332 | CreateObjectStateEventInterface::class |
|
| 333 | ); |
|
| 334 | ||
| 335 | $parameters = [ |
|
| 336 | $this->createMock(ObjectStateGroup::class), |
|
| 337 | $this->createMock(ObjectStateCreateStruct::class), |
|
| 338 | ]; |
|
| 339 | ||
| 340 | $objectState = $this->createMock(ObjectState::class); |
|
| 341 | $eventObjectState = $this->createMock(ObjectState::class); |
|
| 342 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 343 | $innerServiceMock->method('createObjectState')->willReturn($objectState); |
|
| 344 | ||
| 345 | $traceableEventDispatcher->addListener(BeforeCreateObjectStateEventInterface::class, function (BeforeCreateObjectStateEventInterface $event) use ($eventObjectState) { |
|
| 346 | $event->setObjectState($eventObjectState); |
|
| 347 | }, 10); |
|
| 348 | ||
| 349 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 350 | $result = $service->createObjectState(...$parameters); |
|
| 351 | ||
| 352 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 353 | ||
| 354 | $this->assertSame($eventObjectState, $result); |
|
| 355 | $this->assertSame($calledListeners, [ |
|
| 356 | [BeforeCreateObjectStateEventInterface::class, 10], |
|
| 357 | [BeforeCreateObjectStateEventInterface::class, 0], |
|
| 358 | [CreateObjectStateEventInterface::class, 0], |
|
| 359 | ]); |
|
| 360 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 361 | } |
|
| 362 | ||
| 363 | public function testCreateObjectStateStopPropagationInBeforeEvents() |
|
| 364 | { |
|
| @@ 430-463 (lines=34) @@ | ||
| 427 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 428 | } |
|
| 429 | ||
| 430 | public function testReturnUpdateObjectStateGroupResultInBeforeEvents() |
|
| 431 | { |
|
| 432 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 433 | BeforeUpdateObjectStateGroupEventInterface::class, |
|
| 434 | UpdateObjectStateGroupEventInterface::class |
|
| 435 | ); |
|
| 436 | ||
| 437 | $parameters = [ |
|
| 438 | $this->createMock(ObjectStateGroup::class), |
|
| 439 | $this->createMock(ObjectStateGroupUpdateStruct::class), |
|
| 440 | ]; |
|
| 441 | ||
| 442 | $updatedObjectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 443 | $eventUpdatedObjectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 444 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 445 | $innerServiceMock->method('updateObjectStateGroup')->willReturn($updatedObjectStateGroup); |
|
| 446 | ||
| 447 | $traceableEventDispatcher->addListener(BeforeUpdateObjectStateGroupEventInterface::class, function (BeforeUpdateObjectStateGroupEventInterface $event) use ($eventUpdatedObjectStateGroup) { |
|
| 448 | $event->setUpdatedObjectStateGroup($eventUpdatedObjectStateGroup); |
|
| 449 | }, 10); |
|
| 450 | ||
| 451 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 452 | $result = $service->updateObjectStateGroup(...$parameters); |
|
| 453 | ||
| 454 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 455 | ||
| 456 | $this->assertSame($eventUpdatedObjectStateGroup, $result); |
|
| 457 | $this->assertSame($calledListeners, [ |
|
| 458 | [BeforeUpdateObjectStateGroupEventInterface::class, 10], |
|
| 459 | [BeforeUpdateObjectStateGroupEventInterface::class, 0], |
|
| 460 | [UpdateObjectStateGroupEventInterface::class, 0], |
|
| 461 | ]); |
|
| 462 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 463 | } |
|
| 464 | ||
| 465 | public function testUpdateObjectStateGroupStopPropagationInBeforeEvents() |
|
| 466 | { |
|
| @@ 148-181 (lines=34) @@ | ||
| 145 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 146 | } |
|
| 147 | ||
| 148 | public function testReturnUpdateRoleResultInBeforeEvents() |
|
| 149 | { |
|
| 150 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 151 | BeforeUpdateRoleEventInterface::class, |
|
| 152 | UpdateRoleEventInterface::class |
|
| 153 | ); |
|
| 154 | ||
| 155 | $parameters = [ |
|
| 156 | $this->createMock(Role::class), |
|
| 157 | $this->createMock(RoleUpdateStruct::class), |
|
| 158 | ]; |
|
| 159 | ||
| 160 | $updatedRole = $this->createMock(Role::class); |
|
| 161 | $eventUpdatedRole = $this->createMock(Role::class); |
|
| 162 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 163 | $innerServiceMock->method('updateRole')->willReturn($updatedRole); |
|
| 164 | ||
| 165 | $traceableEventDispatcher->addListener(BeforeUpdateRoleEventInterface::class, function (BeforeUpdateRoleEventInterface $event) use ($eventUpdatedRole) { |
|
| 166 | $event->setUpdatedRole($eventUpdatedRole); |
|
| 167 | }, 10); |
|
| 168 | ||
| 169 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 170 | $result = $service->updateRole(...$parameters); |
|
| 171 | ||
| 172 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 173 | ||
| 174 | $this->assertSame($eventUpdatedRole, $result); |
|
| 175 | $this->assertSame($calledListeners, [ |
|
| 176 | [BeforeUpdateRoleEventInterface::class, 10], |
|
| 177 | [BeforeUpdateRoleEventInterface::class, 0], |
|
| 178 | [UpdateRoleEventInterface::class, 0], |
|
| 179 | ]); |
|
| 180 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 181 | } |
|
| 182 | ||
| 183 | public function testUpdateRoleStopPropagationInBeforeEvents() |
|
| 184 | { |
|
| @@ 368-401 (lines=34) @@ | ||
| 365 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 366 | } |
|
| 367 | ||
| 368 | public function testReturnAddPolicyResultInBeforeEvents() |
|
| 369 | { |
|
| 370 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 371 | BeforeAddPolicyEventInterface::class, |
|
| 372 | AddPolicyEventInterface::class |
|
| 373 | ); |
|
| 374 | ||
| 375 | $parameters = [ |
|
| 376 | $this->createMock(Role::class), |
|
| 377 | $this->createMock(PolicyCreateStruct::class), |
|
| 378 | ]; |
|
| 379 | ||
| 380 | $updatedRole = $this->createMock(Role::class); |
|
| 381 | $eventUpdatedRole = $this->createMock(Role::class); |
|
| 382 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 383 | $innerServiceMock->method('addPolicy')->willReturn($updatedRole); |
|
| 384 | ||
| 385 | $traceableEventDispatcher->addListener(BeforeAddPolicyEventInterface::class, function (BeforeAddPolicyEventInterface $event) use ($eventUpdatedRole) { |
|
| 386 | $event->setUpdatedRole($eventUpdatedRole); |
|
| 387 | }, 10); |
|
| 388 | ||
| 389 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 390 | $result = $service->addPolicy(...$parameters); |
|
| 391 | ||
| 392 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 393 | ||
| 394 | $this->assertSame($eventUpdatedRole, $result); |
|
| 395 | $this->assertSame($calledListeners, [ |
|
| 396 | [BeforeAddPolicyEventInterface::class, 10], |
|
| 397 | [BeforeAddPolicyEventInterface::class, 0], |
|
| 398 | [AddPolicyEventInterface::class, 0], |
|
| 399 | ]); |
|
| 400 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 401 | } |
|
| 402 | ||
| 403 | public function testAddPolicyStopPropagationInBeforeEvents() |
|
| 404 | { |
|
| @@ 470-503 (lines=34) @@ | ||
| 467 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 468 | } |
|
| 469 | ||
| 470 | public function testReturnUpdateRoleDraftResultInBeforeEvents() |
|
| 471 | { |
|
| 472 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 473 | BeforeUpdateRoleDraftEventInterface::class, |
|
| 474 | UpdateRoleDraftEventInterface::class |
|
| 475 | ); |
|
| 476 | ||
| 477 | $parameters = [ |
|
| 478 | $this->createMock(RoleDraft::class), |
|
| 479 | $this->createMock(RoleUpdateStruct::class), |
|
| 480 | ]; |
|
| 481 | ||
| 482 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 483 | $eventUpdatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 484 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 485 | $innerServiceMock->method('updateRoleDraft')->willReturn($updatedRoleDraft); |
|
| 486 | ||
| 487 | $traceableEventDispatcher->addListener(BeforeUpdateRoleDraftEventInterface::class, function (BeforeUpdateRoleDraftEventInterface $event) use ($eventUpdatedRoleDraft) { |
|
| 488 | $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); |
|
| 489 | }, 10); |
|
| 490 | ||
| 491 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 492 | $result = $service->updateRoleDraft(...$parameters); |
|
| 493 | ||
| 494 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 495 | ||
| 496 | $this->assertSame($eventUpdatedRoleDraft, $result); |
|
| 497 | $this->assertSame($calledListeners, [ |
|
| 498 | [BeforeUpdateRoleDraftEventInterface::class, 10], |
|
| 499 | [BeforeUpdateRoleDraftEventInterface::class, 0], |
|
| 500 | [UpdateRoleDraftEventInterface::class, 0], |
|
| 501 | ]); |
|
| 502 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 503 | } |
|
| 504 | ||
| 505 | public function testUpdateRoleDraftStopPropagationInBeforeEvents() |
|
| 506 | { |
|
| @@ 796-828 (lines=33) @@ | ||
| 793 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 794 | } |
|
| 795 | ||
| 796 | public function testReturnCreateRoleResultInBeforeEvents() |
|
| 797 | { |
|
| 798 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 799 | BeforeCreateRoleEventInterface::class, |
|
| 800 | CreateRoleEventInterface::class |
|
| 801 | ); |
|
| 802 | ||
| 803 | $parameters = [ |
|
| 804 | $this->createMock(RoleCreateStruct::class), |
|
| 805 | ]; |
|
| 806 | ||
| 807 | $roleDraft = $this->createMock(RoleDraft::class); |
|
| 808 | $eventRoleDraft = $this->createMock(RoleDraft::class); |
|
| 809 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 810 | $innerServiceMock->method('createRole')->willReturn($roleDraft); |
|
| 811 | ||
| 812 | $traceableEventDispatcher->addListener(BeforeCreateRoleEventInterface::class, function (BeforeCreateRoleEventInterface $event) use ($eventRoleDraft) { |
|
| 813 | $event->setRoleDraft($eventRoleDraft); |
|
| 814 | }, 10); |
|
| 815 | ||
| 816 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 817 | $result = $service->createRole(...$parameters); |
|
| 818 | ||
| 819 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 820 | ||
| 821 | $this->assertSame($eventRoleDraft, $result); |
|
| 822 | $this->assertSame($calledListeners, [ |
|
| 823 | [BeforeCreateRoleEventInterface::class, 10], |
|
| 824 | [BeforeCreateRoleEventInterface::class, 0], |
|
| 825 | [CreateRoleEventInterface::class, 0], |
|
| 826 | ]); |
|
| 827 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 828 | } |
|
| 829 | ||
| 830 | public function testCreateRoleStopPropagationInBeforeEvents() |
|
| 831 | { |
|
| @@ 896-929 (lines=34) @@ | ||
| 893 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 894 | } |
|
| 895 | ||
| 896 | public function testReturnRemovePolicyByRoleDraftResultInBeforeEvents() |
|
| 897 | { |
|
| 898 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 899 | BeforeRemovePolicyByRoleDraftEventInterface::class, |
|
| 900 | RemovePolicyByRoleDraftEventInterface::class |
|
| 901 | ); |
|
| 902 | ||
| 903 | $parameters = [ |
|
| 904 | $this->createMock(RoleDraft::class), |
|
| 905 | $this->createMock(PolicyDraft::class), |
|
| 906 | ]; |
|
| 907 | ||
| 908 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 909 | $eventUpdatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 910 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 911 | $innerServiceMock->method('removePolicyByRoleDraft')->willReturn($updatedRoleDraft); |
|
| 912 | ||
| 913 | $traceableEventDispatcher->addListener(BeforeRemovePolicyByRoleDraftEventInterface::class, function (BeforeRemovePolicyByRoleDraftEventInterface $event) use ($eventUpdatedRoleDraft) { |
|
| 914 | $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); |
|
| 915 | }, 10); |
|
| 916 | ||
| 917 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 918 | $result = $service->removePolicyByRoleDraft(...$parameters); |
|
| 919 | ||
| 920 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 921 | ||
| 922 | $this->assertSame($eventUpdatedRoleDraft, $result); |
|
| 923 | $this->assertSame($calledListeners, [ |
|
| 924 | [BeforeRemovePolicyByRoleDraftEventInterface::class, 10], |
|
| 925 | [BeforeRemovePolicyByRoleDraftEventInterface::class, 0], |
|
| 926 | [RemovePolicyByRoleDraftEventInterface::class, 0], |
|
| 927 | ]); |
|
| 928 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 929 | } |
|
| 930 | ||
| 931 | public function testRemovePolicyByRoleDraftStopPropagationInBeforeEvents() |
|
| 932 | { |
|
| @@ 998-1031 (lines=34) @@ | ||
| 995 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 996 | } |
|
| 997 | ||
| 998 | public function testReturnAddPolicyByRoleDraftResultInBeforeEvents() |
|
| 999 | { |
|
| 1000 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1001 | BeforeAddPolicyByRoleDraftEventInterface::class, |
|
| 1002 | AddPolicyByRoleDraftEventInterface::class |
|
| 1003 | ); |
|
| 1004 | ||
| 1005 | $parameters = [ |
|
| 1006 | $this->createMock(RoleDraft::class), |
|
| 1007 | $this->createMock(PolicyCreateStruct::class), |
|
| 1008 | ]; |
|
| 1009 | ||
| 1010 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 1011 | $eventUpdatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 1012 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 1013 | $innerServiceMock->method('addPolicyByRoleDraft')->willReturn($updatedRoleDraft); |
|
| 1014 | ||
| 1015 | $traceableEventDispatcher->addListener(BeforeAddPolicyByRoleDraftEventInterface::class, function (BeforeAddPolicyByRoleDraftEventInterface $event) use ($eventUpdatedRoleDraft) { |
|
| 1016 | $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); |
|
| 1017 | }, 10); |
|
| 1018 | ||
| 1019 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 1020 | $result = $service->addPolicyByRoleDraft(...$parameters); |
|
| 1021 | ||
| 1022 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1023 | ||
| 1024 | $this->assertSame($eventUpdatedRoleDraft, $result); |
|
| 1025 | $this->assertSame($calledListeners, [ |
|
| 1026 | [BeforeAddPolicyByRoleDraftEventInterface::class, 10], |
|
| 1027 | [BeforeAddPolicyByRoleDraftEventInterface::class, 0], |
|
| 1028 | [AddPolicyByRoleDraftEventInterface::class, 0], |
|
| 1029 | ]); |
|
| 1030 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1031 | } |
|
| 1032 | ||
| 1033 | public function testAddPolicyByRoleDraftStopPropagationInBeforeEvents() |
|
| 1034 | { |
|
| @@ 1270-1302 (lines=33) @@ | ||
| 1267 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1268 | } |
|
| 1269 | ||
| 1270 | public function testReturnCreateRoleDraftResultInBeforeEvents() |
|
| 1271 | { |
|
| 1272 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1273 | BeforeCreateRoleDraftEventInterface::class, |
|
| 1274 | CreateRoleDraftEventInterface::class |
|
| 1275 | ); |
|
| 1276 | ||
| 1277 | $parameters = [ |
|
| 1278 | $this->createMock(Role::class), |
|
| 1279 | ]; |
|
| 1280 | ||
| 1281 | $roleDraft = $this->createMock(RoleDraft::class); |
|
| 1282 | $eventRoleDraft = $this->createMock(RoleDraft::class); |
|
| 1283 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 1284 | $innerServiceMock->method('createRoleDraft')->willReturn($roleDraft); |
|
| 1285 | ||
| 1286 | $traceableEventDispatcher->addListener(BeforeCreateRoleDraftEventInterface::class, function (BeforeCreateRoleDraftEventInterface $event) use ($eventRoleDraft) { |
|
| 1287 | $event->setRoleDraft($eventRoleDraft); |
|
| 1288 | }, 10); |
|
| 1289 | ||
| 1290 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 1291 | $result = $service->createRoleDraft(...$parameters); |
|
| 1292 | ||
| 1293 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1294 | ||
| 1295 | $this->assertSame($eventRoleDraft, $result); |
|
| 1296 | $this->assertSame($calledListeners, [ |
|
| 1297 | [BeforeCreateRoleDraftEventInterface::class, 10], |
|
| 1298 | [BeforeCreateRoleDraftEventInterface::class, 0], |
|
| 1299 | [CreateRoleDraftEventInterface::class, 0], |
|
| 1300 | ]); |
|
| 1301 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1302 | } |
|
| 1303 | ||
| 1304 | public function testCreateRoleDraftStopPropagationInBeforeEvents() |
|
| 1305 | { |
|
| @@ 1370-1403 (lines=34) @@ | ||
| 1367 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1368 | } |
|
| 1369 | ||
| 1370 | public function testReturnUpdatePolicyResultInBeforeEvents() |
|
| 1371 | { |
|
| 1372 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1373 | BeforeUpdatePolicyEventInterface::class, |
|
| 1374 | UpdatePolicyEventInterface::class |
|
| 1375 | ); |
|
| 1376 | ||
| 1377 | $parameters = [ |
|
| 1378 | $this->createMock(Policy::class), |
|
| 1379 | $this->createMock(PolicyUpdateStruct::class), |
|
| 1380 | ]; |
|
| 1381 | ||
| 1382 | $updatedPolicy = $this->createMock(Policy::class); |
|
| 1383 | $eventUpdatedPolicy = $this->createMock(Policy::class); |
|
| 1384 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 1385 | $innerServiceMock->method('updatePolicy')->willReturn($updatedPolicy); |
|
| 1386 | ||
| 1387 | $traceableEventDispatcher->addListener(BeforeUpdatePolicyEventInterface::class, function (BeforeUpdatePolicyEventInterface $event) use ($eventUpdatedPolicy) { |
|
| 1388 | $event->setUpdatedPolicy($eventUpdatedPolicy); |
|
| 1389 | }, 10); |
|
| 1390 | ||
| 1391 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 1392 | $result = $service->updatePolicy(...$parameters); |
|
| 1393 | ||
| 1394 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1395 | ||
| 1396 | $this->assertSame($eventUpdatedPolicy, $result); |
|
| 1397 | $this->assertSame($calledListeners, [ |
|
| 1398 | [BeforeUpdatePolicyEventInterface::class, 10], |
|
| 1399 | [BeforeUpdatePolicyEventInterface::class, 0], |
|
| 1400 | [UpdatePolicyEventInterface::class, 0], |
|
| 1401 | ]); |
|
| 1402 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1403 | } |
|
| 1404 | ||
| 1405 | public function testUpdatePolicyStopPropagationInBeforeEvents() |
|
| 1406 | { |
|
| @@ 117-150 (lines=34) @@ | ||
| 114 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 115 | } |
|
| 116 | ||
| 117 | public function testReturnUpdateSectionResultInBeforeEvents() |
|
| 118 | { |
|
| 119 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 120 | BeforeUpdateSectionEventInterface::class, |
|
| 121 | UpdateSectionEventInterface::class |
|
| 122 | ); |
|
| 123 | ||
| 124 | $parameters = [ |
|
| 125 | $this->createMock(Section::class), |
|
| 126 | $this->createMock(SectionUpdateStruct::class), |
|
| 127 | ]; |
|
| 128 | ||
| 129 | $updatedSection = $this->createMock(Section::class); |
|
| 130 | $eventUpdatedSection = $this->createMock(Section::class); |
|
| 131 | $innerServiceMock = $this->createMock(SectionServiceInterface::class); |
|
| 132 | $innerServiceMock->method('updateSection')->willReturn($updatedSection); |
|
| 133 | ||
| 134 | $traceableEventDispatcher->addListener(BeforeUpdateSectionEventInterface::class, function (BeforeUpdateSectionEventInterface $event) use ($eventUpdatedSection) { |
|
| 135 | $event->setUpdatedSection($eventUpdatedSection); |
|
| 136 | }, 10); |
|
| 137 | ||
| 138 | $service = new SectionService($innerServiceMock, $traceableEventDispatcher); |
|
| 139 | $result = $service->updateSection(...$parameters); |
|
| 140 | ||
| 141 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 142 | ||
| 143 | $this->assertSame($eventUpdatedSection, $result); |
|
| 144 | $this->assertSame($calledListeners, [ |
|
| 145 | [BeforeUpdateSectionEventInterface::class, 10], |
|
| 146 | [BeforeUpdateSectionEventInterface::class, 0], |
|
| 147 | [UpdateSectionEventInterface::class, 0], |
|
| 148 | ]); |
|
| 149 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 150 | } |
|
| 151 | ||
| 152 | public function testUpdateSectionStopPropagationInBeforeEvents() |
|
| 153 | { |
|
| @@ 334-366 (lines=33) @@ | ||
| 331 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 332 | } |
|
| 333 | ||
| 334 | public function testReturnCreateSectionResultInBeforeEvents() |
|
| 335 | { |
|
| 336 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 337 | BeforeCreateSectionEventInterface::class, |
|
| 338 | CreateSectionEventInterface::class |
|
| 339 | ); |
|
| 340 | ||
| 341 | $parameters = [ |
|
| 342 | $this->createMock(SectionCreateStruct::class), |
|
| 343 | ]; |
|
| 344 | ||
| 345 | $section = $this->createMock(Section::class); |
|
| 346 | $eventSection = $this->createMock(Section::class); |
|
| 347 | $innerServiceMock = $this->createMock(SectionServiceInterface::class); |
|
| 348 | $innerServiceMock->method('createSection')->willReturn($section); |
|
| 349 | ||
| 350 | $traceableEventDispatcher->addListener(BeforeCreateSectionEventInterface::class, function (BeforeCreateSectionEventInterface $event) use ($eventSection) { |
|
| 351 | $event->setSection($eventSection); |
|
| 352 | }, 10); |
|
| 353 | ||
| 354 | $service = new SectionService($innerServiceMock, $traceableEventDispatcher); |
|
| 355 | $result = $service->createSection(...$parameters); |
|
| 356 | ||
| 357 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 358 | ||
| 359 | $this->assertSame($eventSection, $result); |
|
| 360 | $this->assertSame($calledListeners, [ |
|
| 361 | [BeforeCreateSectionEventInterface::class, 10], |
|
| 362 | [BeforeCreateSectionEventInterface::class, 0], |
|
| 363 | [CreateSectionEventInterface::class, 0], |
|
| 364 | ]); |
|
| 365 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 366 | } |
|
| 367 | ||
| 368 | public function testCreateSectionStopPropagationInBeforeEvents() |
|
| 369 | { |
|
| @@ 53-84 (lines=32) @@ | ||
| 50 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 51 | } |
|
| 52 | ||
| 53 | public function testReturnEmptyTrashResultInBeforeEvents() |
|
| 54 | { |
|
| 55 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 56 | BeforeEmptyTrashEventInterface::class, |
|
| 57 | EmptyTrashEventInterface::class |
|
| 58 | ); |
|
| 59 | ||
| 60 | $parameters = [ |
|
| 61 | ]; |
|
| 62 | ||
| 63 | $resultList = $this->createMock(TrashItemDeleteResultList::class); |
|
| 64 | $eventResultList = $this->createMock(TrashItemDeleteResultList::class); |
|
| 65 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 66 | $innerServiceMock->method('emptyTrash')->willReturn($resultList); |
|
| 67 | ||
| 68 | $traceableEventDispatcher->addListener(BeforeEmptyTrashEventInterface::class, function (BeforeEmptyTrashEventInterface $event) use ($eventResultList) { |
|
| 69 | $event->setResultList($eventResultList); |
|
| 70 | }, 10); |
|
| 71 | ||
| 72 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 73 | $result = $service->emptyTrash(...$parameters); |
|
| 74 | ||
| 75 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 76 | ||
| 77 | $this->assertSame($eventResultList, $result); |
|
| 78 | $this->assertSame($calledListeners, [ |
|
| 79 | [BeforeEmptyTrashEventInterface::class, 10], |
|
| 80 | [BeforeEmptyTrashEventInterface::class, 0], |
|
| 81 | [EmptyTrashEventInterface::class, 0], |
|
| 82 | ]); |
|
| 83 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 84 | } |
|
| 85 | ||
| 86 | public function testEmptyTrashStopPropagationInBeforeEvents() |
|
| 87 | { |
|
| @@ 150-182 (lines=33) @@ | ||
| 147 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 148 | } |
|
| 149 | ||
| 150 | public function testReturnTrashResultInBeforeEvents() |
|
| 151 | { |
|
| 152 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 153 | BeforeTrashEventInterface::class, |
|
| 154 | TrashEventInterface::class |
|
| 155 | ); |
|
| 156 | ||
| 157 | $parameters = [ |
|
| 158 | $this->createMock(Location::class), |
|
| 159 | ]; |
|
| 160 | ||
| 161 | $trashItem = $this->createMock(TrashItem::class); |
|
| 162 | $eventTrashItem = $this->createMock(TrashItem::class); |
|
| 163 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 164 | $innerServiceMock->method('trash')->willReturn($trashItem); |
|
| 165 | ||
| 166 | $traceableEventDispatcher->addListener(BeforeTrashEventInterface::class, function (BeforeTrashEventInterface $event) use ($eventTrashItem) { |
|
| 167 | $event->setResult($eventTrashItem); |
|
| 168 | }, 10); |
|
| 169 | ||
| 170 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 171 | $result = $service->trash(...$parameters); |
|
| 172 | ||
| 173 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 174 | ||
| 175 | $this->assertSame($eventTrashItem, $result); |
|
| 176 | $this->assertSame($calledListeners, [ |
|
| 177 | [BeforeTrashEventInterface::class, 10], |
|
| 178 | [BeforeTrashEventInterface::class, 0], |
|
| 179 | [TrashEventInterface::class, 0], |
|
| 180 | ]); |
|
| 181 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 182 | } |
|
| 183 | ||
| 184 | public function testTrashStopPropagationInBeforeEvents() |
|
| 185 | { |
|
| @@ 250-283 (lines=34) @@ | ||
| 247 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 248 | } |
|
| 249 | ||
| 250 | public function testReturnRecoverResultInBeforeEvents() |
|
| 251 | { |
|
| 252 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 253 | BeforeRecoverEventInterface::class, |
|
| 254 | RecoverEventInterface::class |
|
| 255 | ); |
|
| 256 | ||
| 257 | $parameters = [ |
|
| 258 | $this->createMock(TrashItem::class), |
|
| 259 | $this->createMock(Location::class), |
|
| 260 | ]; |
|
| 261 | ||
| 262 | $location = $this->createMock(Location::class); |
|
| 263 | $eventLocation = $this->createMock(Location::class); |
|
| 264 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 265 | $innerServiceMock->method('recover')->willReturn($location); |
|
| 266 | ||
| 267 | $traceableEventDispatcher->addListener(BeforeRecoverEventInterface::class, function (BeforeRecoverEventInterface $event) use ($eventLocation) { |
|
| 268 | $event->setLocation($eventLocation); |
|
| 269 | }, 10); |
|
| 270 | ||
| 271 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 272 | $result = $service->recover(...$parameters); |
|
| 273 | ||
| 274 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 275 | ||
| 276 | $this->assertSame($eventLocation, $result); |
|
| 277 | $this->assertSame($calledListeners, [ |
|
| 278 | [BeforeRecoverEventInterface::class, 10], |
|
| 279 | [BeforeRecoverEventInterface::class, 0], |
|
| 280 | [RecoverEventInterface::class, 0], |
|
| 281 | ]); |
|
| 282 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 283 | } |
|
| 284 | ||
| 285 | public function testRecoverStopPropagationInBeforeEvents() |
|
| 286 | { |
|
| @@ 351-383 (lines=33) @@ | ||
| 348 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 349 | } |
|
| 350 | ||
| 351 | public function testReturnDeleteTrashItemResultInBeforeEvents() |
|
| 352 | { |
|
| 353 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 354 | BeforeDeleteTrashItemEventInterface::class, |
|
| 355 | DeleteTrashItemEventInterface::class |
|
| 356 | ); |
|
| 357 | ||
| 358 | $parameters = [ |
|
| 359 | $this->createMock(TrashItem::class), |
|
| 360 | ]; |
|
| 361 | ||
| 362 | $result = $this->createMock(TrashItemDeleteResult::class); |
|
| 363 | $eventResult = $this->createMock(TrashItemDeleteResult::class); |
|
| 364 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 365 | $innerServiceMock->method('deleteTrashItem')->willReturn($result); |
|
| 366 | ||
| 367 | $traceableEventDispatcher->addListener(BeforeDeleteTrashItemEventInterface::class, function (BeforeDeleteTrashItemEventInterface $event) use ($eventResult) { |
|
| 368 | $event->setResult($eventResult); |
|
| 369 | }, 10); |
|
| 370 | ||
| 371 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 372 | $result = $service->deleteTrashItem(...$parameters); |
|
| 373 | ||
| 374 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 375 | ||
| 376 | $this->assertSame($eventResult, $result); |
|
| 377 | $this->assertSame($calledListeners, [ |
|
| 378 | [BeforeDeleteTrashItemEventInterface::class, 10], |
|
| 379 | [BeforeDeleteTrashItemEventInterface::class, 0], |
|
| 380 | [DeleteTrashItemEventInterface::class, 0], |
|
| 381 | ]); |
|
| 382 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 383 | } |
|
| 384 | ||
| 385 | public function testDeleteTrashItemStopPropagationInBeforeEvents() |
|
| 386 | { |
|
| @@ 47-80 (lines=34) @@ | ||
| 44 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 45 | } |
|
| 46 | ||
| 47 | public function testReturnUpdateUrlResultInBeforeEvents() |
|
| 48 | { |
|
| 49 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 50 | BeforeUpdateUrlEventInterface::class, |
|
| 51 | UpdateUrlEventInterface::class |
|
| 52 | ); |
|
| 53 | ||
| 54 | $parameters = [ |
|
| 55 | $this->createMock(URL::class), |
|
| 56 | $this->createMock(URLUpdateStruct::class), |
|
| 57 | ]; |
|
| 58 | ||
| 59 | $updatedUrl = $this->createMock(URL::class); |
|
| 60 | $eventUpdatedUrl = $this->createMock(URL::class); |
|
| 61 | $innerServiceMock = $this->createMock(URLServiceInterface::class); |
|
| 62 | $innerServiceMock->method('updateUrl')->willReturn($updatedUrl); |
|
| 63 | ||
| 64 | $traceableEventDispatcher->addListener(BeforeUpdateUrlEventInterface::class, function (BeforeUpdateUrlEventInterface $event) use ($eventUpdatedUrl) { |
|
| 65 | $event->setUpdatedUrl($eventUpdatedUrl); |
|
| 66 | }, 10); |
|
| 67 | ||
| 68 | $service = new URLService($innerServiceMock, $traceableEventDispatcher); |
|
| 69 | $result = $service->updateUrl(...$parameters); |
|
| 70 | ||
| 71 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 72 | ||
| 73 | $this->assertSame($eventUpdatedUrl, $result); |
|
| 74 | $this->assertSame($calledListeners, [ |
|
| 75 | [BeforeUpdateUrlEventInterface::class, 10], |
|
| 76 | [BeforeUpdateUrlEventInterface::class, 0], |
|
| 77 | [UpdateUrlEventInterface::class, 0], |
|
| 78 | ]); |
|
| 79 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 80 | } |
|
| 81 | ||
| 82 | public function testUpdateUrlStopPropagationInBeforeEvents() |
|
| 83 | { |
|
| @@ 212-244 (lines=33) @@ | ||
| 209 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 210 | } |
|
| 211 | ||
| 212 | public function testReturnTranslateResultInBeforeEvents() |
|
| 213 | { |
|
| 214 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 215 | BeforeTranslateEventInterface::class, |
|
| 216 | TranslateEventInterface::class |
|
| 217 | ); |
|
| 218 | ||
| 219 | $parameters = [ |
|
| 220 | 'random_value_5cff79c316d370.25863709', |
|
| 221 | ]; |
|
| 222 | ||
| 223 | $result = $this->createMock(URLWildcardTranslationResult::class); |
|
| 224 | $eventResult = $this->createMock(URLWildcardTranslationResult::class); |
|
| 225 | $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class); |
|
| 226 | $innerServiceMock->method('translate')->willReturn($result); |
|
| 227 | ||
| 228 | $traceableEventDispatcher->addListener(BeforeTranslateEventInterface::class, function (BeforeTranslateEventInterface $event) use ($eventResult) { |
|
| 229 | $event->setResult($eventResult); |
|
| 230 | }, 10); |
|
| 231 | ||
| 232 | $service = new URLWildcardService($innerServiceMock, $traceableEventDispatcher); |
|
| 233 | $result = $service->translate(...$parameters); |
|
| 234 | ||
| 235 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 236 | ||
| 237 | $this->assertSame($eventResult, $result); |
|
| 238 | $this->assertSame($calledListeners, [ |
|
| 239 | [BeforeTranslateEventInterface::class, 10], |
|
| 240 | [BeforeTranslateEventInterface::class, 0], |
|
| 241 | [TranslateEventInterface::class, 0], |
|
| 242 | ]); |
|
| 243 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 244 | } |
|
| 245 | ||
| 246 | public function testTranslateStopPropagationInBeforeEvents() |
|
| 247 | { |
|
| @@ 70-103 (lines=34) @@ | ||
| 67 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 68 | } |
|
| 69 | ||
| 70 | public function testReturnUpdateUserGroupResultInBeforeEvents() |
|
| 71 | { |
|
| 72 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 73 | BeforeUpdateUserGroupEventInterface::class, |
|
| 74 | UpdateUserGroupEventInterface::class |
|
| 75 | ); |
|
| 76 | ||
| 77 | $parameters = [ |
|
| 78 | $this->createMock(UserGroup::class), |
|
| 79 | $this->createMock(UserGroupUpdateStruct::class), |
|
| 80 | ]; |
|
| 81 | ||
| 82 | $updatedUserGroup = $this->createMock(UserGroup::class); |
|
| 83 | $eventUpdatedUserGroup = $this->createMock(UserGroup::class); |
|
| 84 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 85 | $innerServiceMock->method('updateUserGroup')->willReturn($updatedUserGroup); |
|
| 86 | ||
| 87 | $traceableEventDispatcher->addListener(BeforeUpdateUserGroupEventInterface::class, function (BeforeUpdateUserGroupEventInterface $event) use ($eventUpdatedUserGroup) { |
|
| 88 | $event->setUpdatedUserGroup($eventUpdatedUserGroup); |
|
| 89 | }, 10); |
|
| 90 | ||
| 91 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 92 | $result = $service->updateUserGroup(...$parameters); |
|
| 93 | ||
| 94 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 95 | ||
| 96 | $this->assertSame($eventUpdatedUserGroup, $result); |
|
| 97 | $this->assertSame($calledListeners, [ |
|
| 98 | [BeforeUpdateUserGroupEventInterface::class, 10], |
|
| 99 | [BeforeUpdateUserGroupEventInterface::class, 0], |
|
| 100 | [UpdateUserGroupEventInterface::class, 0], |
|
| 101 | ]); |
|
| 102 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 103 | } |
|
| 104 | ||
| 105 | public function testUpdateUserGroupStopPropagationInBeforeEvents() |
|
| 106 | { |
|
| @@ 172-205 (lines=34) @@ | ||
| 169 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 170 | } |
|
| 171 | ||
| 172 | public function testReturnUpdateUserResultInBeforeEvents() |
|
| 173 | { |
|
| 174 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 175 | BeforeUpdateUserEventInterface::class, |
|
| 176 | UpdateUserEventInterface::class |
|
| 177 | ); |
|
| 178 | ||
| 179 | $parameters = [ |
|
| 180 | $this->createMock(User::class), |
|
| 181 | $this->createMock(UserUpdateStruct::class), |
|
| 182 | ]; |
|
| 183 | ||
| 184 | $updatedUser = $this->createMock(User::class); |
|
| 185 | $eventUpdatedUser = $this->createMock(User::class); |
|
| 186 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 187 | $innerServiceMock->method('updateUser')->willReturn($updatedUser); |
|
| 188 | ||
| 189 | $traceableEventDispatcher->addListener(BeforeUpdateUserEventInterface::class, function (BeforeUpdateUserEventInterface $event) use ($eventUpdatedUser) { |
|
| 190 | $event->setUpdatedUser($eventUpdatedUser); |
|
| 191 | }, 10); |
|
| 192 | ||
| 193 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 194 | $result = $service->updateUser(...$parameters); |
|
| 195 | ||
| 196 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 197 | ||
| 198 | $this->assertSame($eventUpdatedUser, $result); |
|
| 199 | $this->assertSame($calledListeners, [ |
|
| 200 | [BeforeUpdateUserEventInterface::class, 10], |
|
| 201 | [BeforeUpdateUserEventInterface::class, 0], |
|
| 202 | [UpdateUserEventInterface::class, 0], |
|
| 203 | ]); |
|
| 204 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 205 | } |
|
| 206 | ||
| 207 | public function testUpdateUserStopPropagationInBeforeEvents() |
|
| 208 | { |
|
| @@ 649-682 (lines=34) @@ | ||
| 646 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 647 | } |
|
| 648 | ||
| 649 | public function testReturnCreateUserResultInBeforeEvents() |
|
| 650 | { |
|
| 651 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 652 | BeforeCreateUserEventInterface::class, |
|
| 653 | CreateUserEventInterface::class |
|
| 654 | ); |
|
| 655 | ||
| 656 | $parameters = [ |
|
| 657 | $this->createMock(UserCreateStruct::class), |
|
| 658 | [], |
|
| 659 | ]; |
|
| 660 | ||
| 661 | $user = $this->createMock(User::class); |
|
| 662 | $eventUser = $this->createMock(User::class); |
|
| 663 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 664 | $innerServiceMock->method('createUser')->willReturn($user); |
|
| 665 | ||
| 666 | $traceableEventDispatcher->addListener(BeforeCreateUserEventInterface::class, function (BeforeCreateUserEventInterface $event) use ($eventUser) { |
|
| 667 | $event->setUser($eventUser); |
|
| 668 | }, 10); |
|
| 669 | ||
| 670 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 671 | $result = $service->createUser(...$parameters); |
|
| 672 | ||
| 673 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 674 | ||
| 675 | $this->assertSame($eventUser, $result); |
|
| 676 | $this->assertSame($calledListeners, [ |
|
| 677 | [BeforeCreateUserEventInterface::class, 10], |
|
| 678 | [BeforeCreateUserEventInterface::class, 0], |
|
| 679 | [CreateUserEventInterface::class, 0], |
|
| 680 | ]); |
|
| 681 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 682 | } |
|
| 683 | ||
| 684 | public function testCreateUserStopPropagationInBeforeEvents() |
|
| 685 | { |
|
| @@ 751-784 (lines=34) @@ | ||
| 748 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 749 | } |
|
| 750 | ||
| 751 | public function testReturnCreateUserGroupResultInBeforeEvents() |
|
| 752 | { |
|
| 753 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 754 | BeforeCreateUserGroupEventInterface::class, |
|
| 755 | CreateUserGroupEventInterface::class |
|
| 756 | ); |
|
| 757 | ||
| 758 | $parameters = [ |
|
| 759 | $this->createMock(UserGroupCreateStruct::class), |
|
| 760 | $this->createMock(UserGroup::class), |
|
| 761 | ]; |
|
| 762 | ||
| 763 | $userGroup = $this->createMock(UserGroup::class); |
|
| 764 | $eventUserGroup = $this->createMock(UserGroup::class); |
|
| 765 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 766 | $innerServiceMock->method('createUserGroup')->willReturn($userGroup); |
|
| 767 | ||
| 768 | $traceableEventDispatcher->addListener(BeforeCreateUserGroupEventInterface::class, function (BeforeCreateUserGroupEventInterface $event) use ($eventUserGroup) { |
|
| 769 | $event->setUserGroup($eventUserGroup); |
|
| 770 | }, 10); |
|
| 771 | ||
| 772 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 773 | $result = $service->createUserGroup(...$parameters); |
|
| 774 | ||
| 775 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 776 | ||
| 777 | $this->assertSame($eventUserGroup, $result); |
|
| 778 | $this->assertSame($calledListeners, [ |
|
| 779 | [BeforeCreateUserGroupEventInterface::class, 10], |
|
| 780 | [BeforeCreateUserGroupEventInterface::class, 0], |
|
| 781 | [CreateUserGroupEventInterface::class, 0], |
|
| 782 | ]); |
|
| 783 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 784 | } |
|
| 785 | ||
| 786 | public function testCreateUserGroupStopPropagationInBeforeEvents() |
|
| 787 | { |
|
| @@ 853-886 (lines=34) @@ | ||
| 850 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 851 | } |
|
| 852 | ||
| 853 | public function testReturnUpdateUserTokenResultInBeforeEvents() |
|
| 854 | { |
|
| 855 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 856 | BeforeUpdateUserTokenEventInterface::class, |
|
| 857 | UpdateUserTokenEventInterface::class |
|
| 858 | ); |
|
| 859 | ||
| 860 | $parameters = [ |
|
| 861 | $this->createMock(User::class), |
|
| 862 | $this->createMock(UserTokenUpdateStruct::class), |
|
| 863 | ]; |
|
| 864 | ||
| 865 | $updatedUser = $this->createMock(User::class); |
|
| 866 | $eventUpdatedUser = $this->createMock(User::class); |
|
| 867 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 868 | $innerServiceMock->method('updateUserToken')->willReturn($updatedUser); |
|
| 869 | ||
| 870 | $traceableEventDispatcher->addListener(BeforeUpdateUserTokenEventInterface::class, function (BeforeUpdateUserTokenEventInterface $event) use ($eventUpdatedUser) { |
|
| 871 | $event->setUpdatedUser($eventUpdatedUser); |
|
| 872 | }, 10); |
|
| 873 | ||
| 874 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 875 | $result = $service->updateUserToken(...$parameters); |
|
| 876 | ||
| 877 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 878 | ||
| 879 | $this->assertSame($eventUpdatedUser, $result); |
|
| 880 | $this->assertSame($calledListeners, [ |
|
| 881 | [BeforeUpdateUserTokenEventInterface::class, 10], |
|
| 882 | [BeforeUpdateUserTokenEventInterface::class, 0], |
|
| 883 | [UpdateUserTokenEventInterface::class, 0], |
|
| 884 | ]); |
|
| 885 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 886 | } |
|
| 887 | ||
| 888 | public function testUpdateUserTokenStopPropagationInBeforeEvents() |
|
| 889 | { |
|