| @@ 317-353 (lines=37) @@ | ||
| 314 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 315 | } |
|
| 316 | ||
| 317 | public function testUpdateContentStopPropagationInBeforeEvents() |
|
| 318 | { |
|
| 319 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 320 | BeforeUpdateContentEventInterface::class, |
|
| 321 | UpdateContentEventInterface::class |
|
| 322 | ); |
|
| 323 | ||
| 324 | $parameters = [ |
|
| 325 | $this->createMock(VersionInfo::class), |
|
| 326 | $this->createMock(ContentUpdateStruct::class), |
|
| 327 | ]; |
|
| 328 | ||
| 329 | $content = $this->createMock(Content::class); |
|
| 330 | $eventContent = $this->createMock(Content::class); |
|
| 331 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 332 | $innerServiceMock->method('updateContent')->willReturn($content); |
|
| 333 | ||
| 334 | $traceableEventDispatcher->addListener(BeforeUpdateContentEventInterface::class, function (BeforeUpdateContentEventInterface $event) use ($eventContent) { |
|
| 335 | $event->setContent($eventContent); |
|
| 336 | $event->stopPropagation(); |
|
| 337 | }, 10); |
|
| 338 | ||
| 339 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 340 | $result = $service->updateContent(...$parameters); |
|
| 341 | ||
| 342 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 343 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 344 | ||
| 345 | $this->assertSame($eventContent, $result); |
|
| 346 | $this->assertSame($calledListeners, [ |
|
| 347 | [BeforeUpdateContentEventInterface::class, 10], |
|
| 348 | ]); |
|
| 349 | $this->assertSame($notCalledListeners, [ |
|
| 350 | [BeforeUpdateContentEventInterface::class, 0], |
|
| 351 | [UpdateContentEventInterface::class, 0], |
|
| 352 | ]); |
|
| 353 | } |
|
| 354 | ||
| 355 | public function testDeleteRelationEvents() |
|
| 356 | { |
|
| @@ 478-514 (lines=37) @@ | ||
| 475 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 476 | } |
|
| 477 | ||
| 478 | public function testCreateContentStopPropagationInBeforeEvents() |
|
| 479 | { |
|
| 480 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 481 | BeforeCreateContentEventInterface::class, |
|
| 482 | CreateContentEventInterface::class |
|
| 483 | ); |
|
| 484 | ||
| 485 | $parameters = [ |
|
| 486 | $this->createMock(ContentCreateStruct::class), |
|
| 487 | [], |
|
| 488 | ]; |
|
| 489 | ||
| 490 | $content = $this->createMock(Content::class); |
|
| 491 | $eventContent = $this->createMock(Content::class); |
|
| 492 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 493 | $innerServiceMock->method('createContent')->willReturn($content); |
|
| 494 | ||
| 495 | $traceableEventDispatcher->addListener(BeforeCreateContentEventInterface::class, function (BeforeCreateContentEventInterface $event) use ($eventContent) { |
|
| 496 | $event->setContent($eventContent); |
|
| 497 | $event->stopPropagation(); |
|
| 498 | }, 10); |
|
| 499 | ||
| 500 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 501 | $result = $service->createContent(...$parameters); |
|
| 502 | ||
| 503 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 504 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 505 | ||
| 506 | $this->assertSame($eventContent, $result); |
|
| 507 | $this->assertSame($calledListeners, [ |
|
| 508 | [BeforeCreateContentEventInterface::class, 10], |
|
| 509 | ]); |
|
| 510 | $this->assertSame($notCalledListeners, [ |
|
| 511 | [BeforeCreateContentEventInterface::class, 0], |
|
| 512 | [CreateContentEventInterface::class, 0], |
|
| 513 | ]); |
|
| 514 | } |
|
| 515 | ||
| 516 | public function testHideContentEvents() |
|
| 517 | { |
|
| @@ 694-730 (lines=37) @@ | ||
| 691 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 692 | } |
|
| 693 | ||
| 694 | public function testAddRelationStopPropagationInBeforeEvents() |
|
| 695 | { |
|
| 696 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 697 | BeforeAddRelationEventInterface::class, |
|
| 698 | AddRelationEventInterface::class |
|
| 699 | ); |
|
| 700 | ||
| 701 | $parameters = [ |
|
| 702 | $this->createMock(VersionInfo::class), |
|
| 703 | $this->createMock(ContentInfo::class), |
|
| 704 | ]; |
|
| 705 | ||
| 706 | $relation = $this->createMock(Relation::class); |
|
| 707 | $eventRelation = $this->createMock(Relation::class); |
|
| 708 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 709 | $innerServiceMock->method('addRelation')->willReturn($relation); |
|
| 710 | ||
| 711 | $traceableEventDispatcher->addListener(BeforeAddRelationEventInterface::class, function (BeforeAddRelationEventInterface $event) use ($eventRelation) { |
|
| 712 | $event->setRelation($eventRelation); |
|
| 713 | $event->stopPropagation(); |
|
| 714 | }, 10); |
|
| 715 | ||
| 716 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 717 | $result = $service->addRelation(...$parameters); |
|
| 718 | ||
| 719 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 720 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 721 | ||
| 722 | $this->assertSame($eventRelation, $result); |
|
| 723 | $this->assertSame($calledListeners, [ |
|
| 724 | [BeforeAddRelationEventInterface::class, 10], |
|
| 725 | ]); |
|
| 726 | $this->assertSame($notCalledListeners, [ |
|
| 727 | [AddRelationEventInterface::class, 0], |
|
| 728 | [BeforeAddRelationEventInterface::class, 0], |
|
| 729 | ]); |
|
| 730 | } |
|
| 731 | ||
| 732 | public function testUpdateContentMetadataEvents() |
|
| 733 | { |
|
| @@ 796-832 (lines=37) @@ | ||
| 793 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 794 | } |
|
| 795 | ||
| 796 | public function testUpdateContentMetadataStopPropagationInBeforeEvents() |
|
| 797 | { |
|
| 798 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 799 | BeforeUpdateContentMetadataEventInterface::class, |
|
| 800 | UpdateContentMetadataEventInterface::class |
|
| 801 | ); |
|
| 802 | ||
| 803 | $parameters = [ |
|
| 804 | $this->createMock(ContentInfo::class), |
|
| 805 | $this->createMock(ContentMetadataUpdateStruct::class), |
|
| 806 | ]; |
|
| 807 | ||
| 808 | $content = $this->createMock(Content::class); |
|
| 809 | $eventContent = $this->createMock(Content::class); |
|
| 810 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 811 | $innerServiceMock->method('updateContentMetadata')->willReturn($content); |
|
| 812 | ||
| 813 | $traceableEventDispatcher->addListener(BeforeUpdateContentMetadataEventInterface::class, function (BeforeUpdateContentMetadataEventInterface $event) use ($eventContent) { |
|
| 814 | $event->setContent($eventContent); |
|
| 815 | $event->stopPropagation(); |
|
| 816 | }, 10); |
|
| 817 | ||
| 818 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 819 | $result = $service->updateContentMetadata(...$parameters); |
|
| 820 | ||
| 821 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 822 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 823 | ||
| 824 | $this->assertSame($eventContent, $result); |
|
| 825 | $this->assertSame($calledListeners, [ |
|
| 826 | [BeforeUpdateContentMetadataEventInterface::class, 10], |
|
| 827 | ]); |
|
| 828 | $this->assertSame($notCalledListeners, [ |
|
| 829 | [BeforeUpdateContentMetadataEventInterface::class, 0], |
|
| 830 | [UpdateContentMetadataEventInterface::class, 0], |
|
| 831 | ]); |
|
| 832 | } |
|
| 833 | ||
| 834 | public function testDeleteTranslationEvents() |
|
| 835 | { |
|
| @@ 957-993 (lines=37) @@ | ||
| 954 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 955 | } |
|
| 956 | ||
| 957 | public function testPublishVersionStopPropagationInBeforeEvents() |
|
| 958 | { |
|
| 959 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 960 | BeforePublishVersionEventInterface::class, |
|
| 961 | PublishVersionEventInterface::class |
|
| 962 | ); |
|
| 963 | ||
| 964 | $parameters = [ |
|
| 965 | $this->createMock(VersionInfo::class), |
|
| 966 | [], |
|
| 967 | ]; |
|
| 968 | ||
| 969 | $content = $this->createMock(Content::class); |
|
| 970 | $eventContent = $this->createMock(Content::class); |
|
| 971 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 972 | $innerServiceMock->method('publishVersion')->willReturn($content); |
|
| 973 | ||
| 974 | $traceableEventDispatcher->addListener(BeforePublishVersionEventInterface::class, function (BeforePublishVersionEventInterface $event) use ($eventContent) { |
|
| 975 | $event->setContent($eventContent); |
|
| 976 | $event->stopPropagation(); |
|
| 977 | }, 10); |
|
| 978 | ||
| 979 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 980 | $result = $service->publishVersion(...$parameters); |
|
| 981 | ||
| 982 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 983 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 984 | ||
| 985 | $this->assertSame($eventContent, $result); |
|
| 986 | $this->assertSame($calledListeners, [ |
|
| 987 | [BeforePublishVersionEventInterface::class, 10], |
|
| 988 | ]); |
|
| 989 | $this->assertSame($notCalledListeners, [ |
|
| 990 | [BeforePublishVersionEventInterface::class, 0], |
|
| 991 | [PublishVersionEventInterface::class, 0], |
|
| 992 | ]); |
|
| 993 | } |
|
| 994 | ||
| 995 | public function testCreateContentDraftEvents() |
|
| 996 | { |
|
| @@ 233-268 (lines=36) @@ | ||
| 230 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 231 | } |
|
| 232 | ||
| 233 | public function testCreateContentTypeDraftStopPropagationInBeforeEvents() |
|
| 234 | { |
|
| 235 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 236 | BeforeCreateContentTypeDraftEventInterface::class, |
|
| 237 | CreateContentTypeDraftEventInterface::class |
|
| 238 | ); |
|
| 239 | ||
| 240 | $parameters = [ |
|
| 241 | $this->createMock(ContentType::class), |
|
| 242 | ]; |
|
| 243 | ||
| 244 | $contentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 245 | $eventContentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 246 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 247 | $innerServiceMock->method('createContentTypeDraft')->willReturn($contentTypeDraft); |
|
| 248 | ||
| 249 | $traceableEventDispatcher->addListener(BeforeCreateContentTypeDraftEventInterface::class, function (BeforeCreateContentTypeDraftEventInterface $event) use ($eventContentTypeDraft) { |
|
| 250 | $event->setContentTypeDraft($eventContentTypeDraft); |
|
| 251 | $event->stopPropagation(); |
|
| 252 | }, 10); |
|
| 253 | ||
| 254 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 255 | $result = $service->createContentTypeDraft(...$parameters); |
|
| 256 | ||
| 257 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 258 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 259 | ||
| 260 | $this->assertSame($eventContentTypeDraft, $result); |
|
| 261 | $this->assertSame($calledListeners, [ |
|
| 262 | [BeforeCreateContentTypeDraftEventInterface::class, 10], |
|
| 263 | ]); |
|
| 264 | $this->assertSame($notCalledListeners, [ |
|
| 265 | [BeforeCreateContentTypeDraftEventInterface::class, 0], |
|
| 266 | [CreateContentTypeDraftEventInterface::class, 0], |
|
| 267 | ]); |
|
| 268 | } |
|
| 269 | ||
| 270 | public function testCreateContentTypeGroupEvents() |
|
| 271 | { |
|
| @@ 332-367 (lines=36) @@ | ||
| 329 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 330 | } |
|
| 331 | ||
| 332 | public function testCreateContentTypeGroupStopPropagationInBeforeEvents() |
|
| 333 | { |
|
| 334 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 335 | BeforeCreateContentTypeGroupEventInterface::class, |
|
| 336 | CreateContentTypeGroupEventInterface::class |
|
| 337 | ); |
|
| 338 | ||
| 339 | $parameters = [ |
|
| 340 | $this->createMock(ContentTypeGroupCreateStruct::class), |
|
| 341 | ]; |
|
| 342 | ||
| 343 | $contentTypeGroup = $this->createMock(ContentTypeGroup::class); |
|
| 344 | $eventContentTypeGroup = $this->createMock(ContentTypeGroup::class); |
|
| 345 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 346 | $innerServiceMock->method('createContentTypeGroup')->willReturn($contentTypeGroup); |
|
| 347 | ||
| 348 | $traceableEventDispatcher->addListener(BeforeCreateContentTypeGroupEventInterface::class, function (BeforeCreateContentTypeGroupEventInterface $event) use ($eventContentTypeGroup) { |
|
| 349 | $event->setContentTypeGroup($eventContentTypeGroup); |
|
| 350 | $event->stopPropagation(); |
|
| 351 | }, 10); |
|
| 352 | ||
| 353 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 354 | $result = $service->createContentTypeGroup(...$parameters); |
|
| 355 | ||
| 356 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 357 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 358 | ||
| 359 | $this->assertSame($eventContentTypeGroup, $result); |
|
| 360 | $this->assertSame($calledListeners, [ |
|
| 361 | [BeforeCreateContentTypeGroupEventInterface::class, 10], |
|
| 362 | ]); |
|
| 363 | $this->assertSame($notCalledListeners, [ |
|
| 364 | [BeforeCreateContentTypeGroupEventInterface::class, 0], |
|
| 365 | [CreateContentTypeGroupEventInterface::class, 0], |
|
| 366 | ]); |
|
| 367 | } |
|
| 368 | ||
| 369 | public function testUpdateContentTypeGroupEvents() |
|
| 370 | { |
|
| @@ 492-528 (lines=37) @@ | ||
| 489 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 490 | } |
|
| 491 | ||
| 492 | public function testCreateContentTypeStopPropagationInBeforeEvents() |
|
| 493 | { |
|
| 494 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 495 | BeforeCreateContentTypeEventInterface::class, |
|
| 496 | CreateContentTypeEventInterface::class |
|
| 497 | ); |
|
| 498 | ||
| 499 | $parameters = [ |
|
| 500 | $this->createMock(ContentTypeCreateStruct::class), |
|
| 501 | [], |
|
| 502 | ]; |
|
| 503 | ||
| 504 | $contentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 505 | $eventContentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 506 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 507 | $innerServiceMock->method('createContentType')->willReturn($contentTypeDraft); |
|
| 508 | ||
| 509 | $traceableEventDispatcher->addListener(BeforeCreateContentTypeEventInterface::class, function (BeforeCreateContentTypeEventInterface $event) use ($eventContentTypeDraft) { |
|
| 510 | $event->setContentTypeDraft($eventContentTypeDraft); |
|
| 511 | $event->stopPropagation(); |
|
| 512 | }, 10); |
|
| 513 | ||
| 514 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 515 | $result = $service->createContentType(...$parameters); |
|
| 516 | ||
| 517 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 518 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 519 | ||
| 520 | $this->assertSame($eventContentTypeDraft, $result); |
|
| 521 | $this->assertSame($calledListeners, [ |
|
| 522 | [BeforeCreateContentTypeEventInterface::class, 10], |
|
| 523 | ]); |
|
| 524 | $this->assertSame($notCalledListeners, [ |
|
| 525 | [BeforeCreateContentTypeEventInterface::class, 0], |
|
| 526 | [CreateContentTypeEventInterface::class, 0], |
|
| 527 | ]); |
|
| 528 | } |
|
| 529 | ||
| 530 | public function testRemoveContentTypeTranslationEvents() |
|
| 531 | { |
|
| @@ 594-630 (lines=37) @@ | ||
| 591 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 592 | } |
|
| 593 | ||
| 594 | public function testRemoveContentTypeTranslationStopPropagationInBeforeEvents() |
|
| 595 | { |
|
| 596 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 597 | BeforeRemoveContentTypeTranslationEventInterface::class, |
|
| 598 | RemoveContentTypeTranslationEventInterface::class |
|
| 599 | ); |
|
| 600 | ||
| 601 | $parameters = [ |
|
| 602 | $this->createMock(ContentTypeDraft::class), |
|
| 603 | 'random_value_5cff79c318f983.61112462', |
|
| 604 | ]; |
|
| 605 | ||
| 606 | $newContentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 607 | $eventNewContentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 608 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 609 | $innerServiceMock->method('removeContentTypeTranslation')->willReturn($newContentTypeDraft); |
|
| 610 | ||
| 611 | $traceableEventDispatcher->addListener(BeforeRemoveContentTypeTranslationEventInterface::class, function (BeforeRemoveContentTypeTranslationEventInterface $event) use ($eventNewContentTypeDraft) { |
|
| 612 | $event->setNewContentTypeDraft($eventNewContentTypeDraft); |
|
| 613 | $event->stopPropagation(); |
|
| 614 | }, 10); |
|
| 615 | ||
| 616 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 617 | $result = $service->removeContentTypeTranslation(...$parameters); |
|
| 618 | ||
| 619 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 620 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 621 | ||
| 622 | $this->assertSame($eventNewContentTypeDraft, $result); |
|
| 623 | $this->assertSame($calledListeners, [ |
|
| 624 | [BeforeRemoveContentTypeTranslationEventInterface::class, 10], |
|
| 625 | ]); |
|
| 626 | $this->assertSame($notCalledListeners, [ |
|
| 627 | [BeforeRemoveContentTypeTranslationEventInterface::class, 0], |
|
| 628 | [RemoveContentTypeTranslationEventInterface::class, 0], |
|
| 629 | ]); |
|
| 630 | } |
|
| 631 | ||
| 632 | public function testUnassignContentTypeGroupEvents() |
|
| 633 | { |
|
| @@ 1107-1143 (lines=37) @@ | ||
| 1104 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1105 | } |
|
| 1106 | ||
| 1107 | public function testCopyContentTypeStopPropagationInBeforeEvents() |
|
| 1108 | { |
|
| 1109 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1110 | BeforeCopyContentTypeEventInterface::class, |
|
| 1111 | CopyContentTypeEventInterface::class |
|
| 1112 | ); |
|
| 1113 | ||
| 1114 | $parameters = [ |
|
| 1115 | $this->createMock(ContentType::class), |
|
| 1116 | $this->createMock(User::class), |
|
| 1117 | ]; |
|
| 1118 | ||
| 1119 | $contentTypeCopy = $this->createMock(ContentType::class); |
|
| 1120 | $eventContentTypeCopy = $this->createMock(ContentType::class); |
|
| 1121 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 1122 | $innerServiceMock->method('copyContentType')->willReturn($contentTypeCopy); |
|
| 1123 | ||
| 1124 | $traceableEventDispatcher->addListener(BeforeCopyContentTypeEventInterface::class, function (BeforeCopyContentTypeEventInterface $event) use ($eventContentTypeCopy) { |
|
| 1125 | $event->setContentTypeCopy($eventContentTypeCopy); |
|
| 1126 | $event->stopPropagation(); |
|
| 1127 | }, 10); |
|
| 1128 | ||
| 1129 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 1130 | $result = $service->copyContentType(...$parameters); |
|
| 1131 | ||
| 1132 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1133 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 1134 | ||
| 1135 | $this->assertSame($eventContentTypeCopy, $result); |
|
| 1136 | $this->assertSame($calledListeners, [ |
|
| 1137 | [BeforeCopyContentTypeEventInterface::class, 10], |
|
| 1138 | ]); |
|
| 1139 | $this->assertSame($notCalledListeners, [ |
|
| 1140 | [BeforeCopyContentTypeEventInterface::class, 0], |
|
| 1141 | [CopyContentTypeEventInterface::class, 0], |
|
| 1142 | ]); |
|
| 1143 | } |
|
| 1144 | } |
|
| 1145 | ||
| @@ 145-180 (lines=36) @@ | ||
| 142 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 143 | } |
|
| 144 | ||
| 145 | public function testCreateLanguageStopPropagationInBeforeEvents() |
|
| 146 | { |
|
| 147 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 148 | BeforeCreateLanguageEventInterface::class, |
|
| 149 | CreateLanguageEventInterface::class |
|
| 150 | ); |
|
| 151 | ||
| 152 | $parameters = [ |
|
| 153 | $this->createMock(LanguageCreateStruct::class), |
|
| 154 | ]; |
|
| 155 | ||
| 156 | $language = $this->createMock(Language::class); |
|
| 157 | $eventLanguage = $this->createMock(Language::class); |
|
| 158 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 159 | $innerServiceMock->method('createLanguage')->willReturn($language); |
|
| 160 | ||
| 161 | $traceableEventDispatcher->addListener(BeforeCreateLanguageEventInterface::class, function (BeforeCreateLanguageEventInterface $event) use ($eventLanguage) { |
|
| 162 | $event->setLanguage($eventLanguage); |
|
| 163 | $event->stopPropagation(); |
|
| 164 | }, 10); |
|
| 165 | ||
| 166 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 167 | $result = $service->createLanguage(...$parameters); |
|
| 168 | ||
| 169 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 170 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 171 | ||
| 172 | $this->assertSame($eventLanguage, $result); |
|
| 173 | $this->assertSame($calledListeners, [ |
|
| 174 | [BeforeCreateLanguageEventInterface::class, 10], |
|
| 175 | ]); |
|
| 176 | $this->assertSame($notCalledListeners, [ |
|
| 177 | [BeforeCreateLanguageEventInterface::class, 0], |
|
| 178 | [CreateLanguageEventInterface::class, 0], |
|
| 179 | ]); |
|
| 180 | } |
|
| 181 | ||
| 182 | public function testUpdateLanguageNameEvents() |
|
| 183 | { |
|
| @@ 246-282 (lines=37) @@ | ||
| 243 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 244 | } |
|
| 245 | ||
| 246 | public function testUpdateLanguageNameStopPropagationInBeforeEvents() |
|
| 247 | { |
|
| 248 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 249 | BeforeUpdateLanguageNameEventInterface::class, |
|
| 250 | UpdateLanguageNameEventInterface::class |
|
| 251 | ); |
|
| 252 | ||
| 253 | $parameters = [ |
|
| 254 | $this->createMock(Language::class), |
|
| 255 | 'random_value_5cff79c3161386.01414999', |
|
| 256 | ]; |
|
| 257 | ||
| 258 | $updatedLanguage = $this->createMock(Language::class); |
|
| 259 | $eventUpdatedLanguage = $this->createMock(Language::class); |
|
| 260 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 261 | $innerServiceMock->method('updateLanguageName')->willReturn($updatedLanguage); |
|
| 262 | ||
| 263 | $traceableEventDispatcher->addListener(BeforeUpdateLanguageNameEventInterface::class, function (BeforeUpdateLanguageNameEventInterface $event) use ($eventUpdatedLanguage) { |
|
| 264 | $event->setUpdatedLanguage($eventUpdatedLanguage); |
|
| 265 | $event->stopPropagation(); |
|
| 266 | }, 10); |
|
| 267 | ||
| 268 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 269 | $result = $service->updateLanguageName(...$parameters); |
|
| 270 | ||
| 271 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 272 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 273 | ||
| 274 | $this->assertSame($eventUpdatedLanguage, $result); |
|
| 275 | $this->assertSame($calledListeners, [ |
|
| 276 | [BeforeUpdateLanguageNameEventInterface::class, 10], |
|
| 277 | ]); |
|
| 278 | $this->assertSame($notCalledListeners, [ |
|
| 279 | [BeforeUpdateLanguageNameEventInterface::class, 0], |
|
| 280 | [UpdateLanguageNameEventInterface::class, 0], |
|
| 281 | ]); |
|
| 282 | } |
|
| 283 | ||
| 284 | public function testDisableLanguageEvents() |
|
| 285 | { |
|
| @@ 346-381 (lines=36) @@ | ||
| 343 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 344 | } |
|
| 345 | ||
| 346 | public function testDisableLanguageStopPropagationInBeforeEvents() |
|
| 347 | { |
|
| 348 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 349 | BeforeDisableLanguageEventInterface::class, |
|
| 350 | DisableLanguageEventInterface::class |
|
| 351 | ); |
|
| 352 | ||
| 353 | $parameters = [ |
|
| 354 | $this->createMock(Language::class), |
|
| 355 | ]; |
|
| 356 | ||
| 357 | $disabledLanguage = $this->createMock(Language::class); |
|
| 358 | $eventDisabledLanguage = $this->createMock(Language::class); |
|
| 359 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 360 | $innerServiceMock->method('disableLanguage')->willReturn($disabledLanguage); |
|
| 361 | ||
| 362 | $traceableEventDispatcher->addListener(BeforeDisableLanguageEventInterface::class, function (BeforeDisableLanguageEventInterface $event) use ($eventDisabledLanguage) { |
|
| 363 | $event->setDisabledLanguage($eventDisabledLanguage); |
|
| 364 | $event->stopPropagation(); |
|
| 365 | }, 10); |
|
| 366 | ||
| 367 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 368 | $result = $service->disableLanguage(...$parameters); |
|
| 369 | ||
| 370 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 371 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 372 | ||
| 373 | $this->assertSame($eventDisabledLanguage, $result); |
|
| 374 | $this->assertSame($calledListeners, [ |
|
| 375 | [BeforeDisableLanguageEventInterface::class, 10], |
|
| 376 | ]); |
|
| 377 | $this->assertSame($notCalledListeners, [ |
|
| 378 | [BeforeDisableLanguageEventInterface::class, 0], |
|
| 379 | [DisableLanguageEventInterface::class, 0], |
|
| 380 | ]); |
|
| 381 | } |
|
| 382 | ||
| 383 | public function testEnableLanguageEvents() |
|
| 384 | { |
|
| @@ 445-480 (lines=36) @@ | ||
| 442 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 443 | } |
|
| 444 | ||
| 445 | public function testEnableLanguageStopPropagationInBeforeEvents() |
|
| 446 | { |
|
| 447 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 448 | BeforeEnableLanguageEventInterface::class, |
|
| 449 | EnableLanguageEventInterface::class |
|
| 450 | ); |
|
| 451 | ||
| 452 | $parameters = [ |
|
| 453 | $this->createMock(Language::class), |
|
| 454 | ]; |
|
| 455 | ||
| 456 | $enabledLanguage = $this->createMock(Language::class); |
|
| 457 | $eventEnabledLanguage = $this->createMock(Language::class); |
|
| 458 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 459 | $innerServiceMock->method('enableLanguage')->willReturn($enabledLanguage); |
|
| 460 | ||
| 461 | $traceableEventDispatcher->addListener(BeforeEnableLanguageEventInterface::class, function (BeforeEnableLanguageEventInterface $event) use ($eventEnabledLanguage) { |
|
| 462 | $event->setEnabledLanguage($eventEnabledLanguage); |
|
| 463 | $event->stopPropagation(); |
|
| 464 | }, 10); |
|
| 465 | ||
| 466 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 467 | $result = $service->enableLanguage(...$parameters); |
|
| 468 | ||
| 469 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 470 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 471 | ||
| 472 | $this->assertSame($eventEnabledLanguage, $result); |
|
| 473 | $this->assertSame($calledListeners, [ |
|
| 474 | [BeforeEnableLanguageEventInterface::class, 10], |
|
| 475 | ]); |
|
| 476 | $this->assertSame($notCalledListeners, [ |
|
| 477 | [BeforeEnableLanguageEventInterface::class, 0], |
|
| 478 | [EnableLanguageEventInterface::class, 0], |
|
| 479 | ]); |
|
| 480 | } |
|
| 481 | } |
|
| 482 | ||
| @@ 98-134 (lines=37) @@ | ||
| 95 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 96 | } |
|
| 97 | ||
| 98 | public function testCopySubtreeStopPropagationInBeforeEvents() |
|
| 99 | { |
|
| 100 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 101 | BeforeCopySubtreeEventInterface::class, |
|
| 102 | CopySubtreeEventInterface::class |
|
| 103 | ); |
|
| 104 | ||
| 105 | $parameters = [ |
|
| 106 | $this->createMock(Location::class), |
|
| 107 | $this->createMock(Location::class), |
|
| 108 | ]; |
|
| 109 | ||
| 110 | $location = $this->createMock(Location::class); |
|
| 111 | $eventLocation = $this->createMock(Location::class); |
|
| 112 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 113 | $innerServiceMock->method('copySubtree')->willReturn($location); |
|
| 114 | ||
| 115 | $traceableEventDispatcher->addListener(BeforeCopySubtreeEventInterface::class, function (BeforeCopySubtreeEventInterface $event) use ($eventLocation) { |
|
| 116 | $event->setLocation($eventLocation); |
|
| 117 | $event->stopPropagation(); |
|
| 118 | }, 10); |
|
| 119 | ||
| 120 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 121 | $result = $service->copySubtree(...$parameters); |
|
| 122 | ||
| 123 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 124 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 125 | ||
| 126 | $this->assertSame($eventLocation, $result); |
|
| 127 | $this->assertSame($calledListeners, [ |
|
| 128 | [BeforeCopySubtreeEventInterface::class, 10], |
|
| 129 | ]); |
|
| 130 | $this->assertSame($notCalledListeners, [ |
|
| 131 | [BeforeCopySubtreeEventInterface::class, 0], |
|
| 132 | [CopySubtreeEventInterface::class, 0], |
|
| 133 | ]); |
|
| 134 | } |
|
| 135 | ||
| 136 | public function testDeleteLocationEvents() |
|
| 137 | { |
|
| @@ 255-290 (lines=36) @@ | ||
| 252 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 253 | } |
|
| 254 | ||
| 255 | public function testUnhideLocationStopPropagationInBeforeEvents() |
|
| 256 | { |
|
| 257 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 258 | BeforeUnhideLocationEventInterface::class, |
|
| 259 | UnhideLocationEventInterface::class |
|
| 260 | ); |
|
| 261 | ||
| 262 | $parameters = [ |
|
| 263 | $this->createMock(Location::class), |
|
| 264 | ]; |
|
| 265 | ||
| 266 | $revealedLocation = $this->createMock(Location::class); |
|
| 267 | $eventRevealedLocation = $this->createMock(Location::class); |
|
| 268 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 269 | $innerServiceMock->method('unhideLocation')->willReturn($revealedLocation); |
|
| 270 | ||
| 271 | $traceableEventDispatcher->addListener(BeforeUnhideLocationEventInterface::class, function (BeforeUnhideLocationEventInterface $event) use ($eventRevealedLocation) { |
|
| 272 | $event->setRevealedLocation($eventRevealedLocation); |
|
| 273 | $event->stopPropagation(); |
|
| 274 | }, 10); |
|
| 275 | ||
| 276 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 277 | $result = $service->unhideLocation(...$parameters); |
|
| 278 | ||
| 279 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 280 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 281 | ||
| 282 | $this->assertSame($eventRevealedLocation, $result); |
|
| 283 | $this->assertSame($calledListeners, [ |
|
| 284 | [BeforeUnhideLocationEventInterface::class, 10], |
|
| 285 | ]); |
|
| 286 | $this->assertSame($notCalledListeners, [ |
|
| 287 | [BeforeUnhideLocationEventInterface::class, 0], |
|
| 288 | [UnhideLocationEventInterface::class, 0], |
|
| 289 | ]); |
|
| 290 | } |
|
| 291 | ||
| 292 | public function testHideLocationEvents() |
|
| 293 | { |
|
| @@ 354-389 (lines=36) @@ | ||
| 351 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 352 | } |
|
| 353 | ||
| 354 | public function testHideLocationStopPropagationInBeforeEvents() |
|
| 355 | { |
|
| 356 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 357 | BeforeHideLocationEventInterface::class, |
|
| 358 | HideLocationEventInterface::class |
|
| 359 | ); |
|
| 360 | ||
| 361 | $parameters = [ |
|
| 362 | $this->createMock(Location::class), |
|
| 363 | ]; |
|
| 364 | ||
| 365 | $hiddenLocation = $this->createMock(Location::class); |
|
| 366 | $eventHiddenLocation = $this->createMock(Location::class); |
|
| 367 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 368 | $innerServiceMock->method('hideLocation')->willReturn($hiddenLocation); |
|
| 369 | ||
| 370 | $traceableEventDispatcher->addListener(BeforeHideLocationEventInterface::class, function (BeforeHideLocationEventInterface $event) use ($eventHiddenLocation) { |
|
| 371 | $event->setHiddenLocation($eventHiddenLocation); |
|
| 372 | $event->stopPropagation(); |
|
| 373 | }, 10); |
|
| 374 | ||
| 375 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 376 | $result = $service->hideLocation(...$parameters); |
|
| 377 | ||
| 378 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 379 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 380 | ||
| 381 | $this->assertSame($eventHiddenLocation, $result); |
|
| 382 | $this->assertSame($calledListeners, [ |
|
| 383 | [BeforeHideLocationEventInterface::class, 10], |
|
| 384 | ]); |
|
| 385 | $this->assertSame($notCalledListeners, [ |
|
| 386 | [BeforeHideLocationEventInterface::class, 0], |
|
| 387 | [HideLocationEventInterface::class, 0], |
|
| 388 | ]); |
|
| 389 | } |
|
| 390 | ||
| 391 | public function testSwapLocationEvents() |
|
| 392 | { |
|
| @@ 573-609 (lines=37) @@ | ||
| 570 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 571 | } |
|
| 572 | ||
| 573 | public function testUpdateLocationStopPropagationInBeforeEvents() |
|
| 574 | { |
|
| 575 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 576 | BeforeUpdateLocationEventInterface::class, |
|
| 577 | UpdateLocationEventInterface::class |
|
| 578 | ); |
|
| 579 | ||
| 580 | $parameters = [ |
|
| 581 | $this->createMock(Location::class), |
|
| 582 | $this->createMock(LocationUpdateStruct::class), |
|
| 583 | ]; |
|
| 584 | ||
| 585 | $updatedLocation = $this->createMock(Location::class); |
|
| 586 | $eventUpdatedLocation = $this->createMock(Location::class); |
|
| 587 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 588 | $innerServiceMock->method('updateLocation')->willReturn($updatedLocation); |
|
| 589 | ||
| 590 | $traceableEventDispatcher->addListener(BeforeUpdateLocationEventInterface::class, function (BeforeUpdateLocationEventInterface $event) use ($eventUpdatedLocation) { |
|
| 591 | $event->setUpdatedLocation($eventUpdatedLocation); |
|
| 592 | $event->stopPropagation(); |
|
| 593 | }, 10); |
|
| 594 | ||
| 595 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 596 | $result = $service->updateLocation(...$parameters); |
|
| 597 | ||
| 598 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 599 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 600 | ||
| 601 | $this->assertSame($eventUpdatedLocation, $result); |
|
| 602 | $this->assertSame($calledListeners, [ |
|
| 603 | [BeforeUpdateLocationEventInterface::class, 10], |
|
| 604 | ]); |
|
| 605 | $this->assertSame($notCalledListeners, [ |
|
| 606 | [BeforeUpdateLocationEventInterface::class, 0], |
|
| 607 | [UpdateLocationEventInterface::class, 0], |
|
| 608 | ]); |
|
| 609 | } |
|
| 610 | ||
| 611 | public function testCreateLocationEvents() |
|
| 612 | { |
|
| @@ 675-711 (lines=37) @@ | ||
| 672 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 673 | } |
|
| 674 | ||
| 675 | public function testCreateLocationStopPropagationInBeforeEvents() |
|
| 676 | { |
|
| 677 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 678 | BeforeCreateLocationEventInterface::class, |
|
| 679 | CreateLocationEventInterface::class |
|
| 680 | ); |
|
| 681 | ||
| 682 | $parameters = [ |
|
| 683 | $this->createMock(ContentInfo::class), |
|
| 684 | $this->createMock(LocationCreateStruct::class), |
|
| 685 | ]; |
|
| 686 | ||
| 687 | $location = $this->createMock(Location::class); |
|
| 688 | $eventLocation = $this->createMock(Location::class); |
|
| 689 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 690 | $innerServiceMock->method('createLocation')->willReturn($location); |
|
| 691 | ||
| 692 | $traceableEventDispatcher->addListener(BeforeCreateLocationEventInterface::class, function (BeforeCreateLocationEventInterface $event) use ($eventLocation) { |
|
| 693 | $event->setLocation($eventLocation); |
|
| 694 | $event->stopPropagation(); |
|
| 695 | }, 10); |
|
| 696 | ||
| 697 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 698 | $result = $service->createLocation(...$parameters); |
|
| 699 | ||
| 700 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 701 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 702 | ||
| 703 | $this->assertSame($eventLocation, $result); |
|
| 704 | $this->assertSame($calledListeners, [ |
|
| 705 | [BeforeCreateLocationEventInterface::class, 10], |
|
| 706 | ]); |
|
| 707 | $this->assertSame($notCalledListeners, [ |
|
| 708 | [BeforeCreateLocationEventInterface::class, 0], |
|
| 709 | [CreateLocationEventInterface::class, 0], |
|
| 710 | ]); |
|
| 711 | } |
|
| 712 | } |
|
| 713 | ||
| @@ 84-119 (lines=36) @@ | ||
| 81 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 82 | } |
|
| 83 | ||
| 84 | public function testCreateNotificationStopPropagationInBeforeEvents() |
|
| 85 | { |
|
| 86 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 87 | BeforeCreateNotificationEventInterface::class, |
|
| 88 | CreateNotificationEventInterface::class |
|
| 89 | ); |
|
| 90 | ||
| 91 | $parameters = [ |
|
| 92 | $this->createMock(CreateStruct::class), |
|
| 93 | ]; |
|
| 94 | ||
| 95 | $notification = $this->createMock(Notification::class); |
|
| 96 | $eventNotification = $this->createMock(Notification::class); |
|
| 97 | $innerServiceMock = $this->createMock(NotificationServiceInterface::class); |
|
| 98 | $innerServiceMock->method('createNotification')->willReturn($notification); |
|
| 99 | ||
| 100 | $traceableEventDispatcher->addListener(BeforeCreateNotificationEventInterface::class, function (BeforeCreateNotificationEventInterface $event) use ($eventNotification) { |
|
| 101 | $event->setNotification($eventNotification); |
|
| 102 | $event->stopPropagation(); |
|
| 103 | }, 10); |
|
| 104 | ||
| 105 | $service = new NotificationService($innerServiceMock, $traceableEventDispatcher); |
|
| 106 | $result = $service->createNotification(...$parameters); |
|
| 107 | ||
| 108 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 109 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 110 | ||
| 111 | $this->assertSame($eventNotification, $result); |
|
| 112 | $this->assertSame($calledListeners, [ |
|
| 113 | [BeforeCreateNotificationEventInterface::class, 10], |
|
| 114 | ]); |
|
| 115 | $this->assertSame($notCalledListeners, [ |
|
| 116 | [BeforeCreateNotificationEventInterface::class, 0], |
|
| 117 | [CreateNotificationEventInterface::class, 0], |
|
| 118 | ]); |
|
| 119 | } |
|
| 120 | ||
| 121 | public function testDeleteNotificationEvents() |
|
| 122 | { |
|
| @@ 160-195 (lines=36) @@ | ||
| 157 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 158 | } |
|
| 159 | ||
| 160 | public function testCreateObjectStateGroupStopPropagationInBeforeEvents() |
|
| 161 | { |
|
| 162 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 163 | BeforeCreateObjectStateGroupEventInterface::class, |
|
| 164 | CreateObjectStateGroupEventInterface::class |
|
| 165 | ); |
|
| 166 | ||
| 167 | $parameters = [ |
|
| 168 | $this->createMock(ObjectStateGroupCreateStruct::class), |
|
| 169 | ]; |
|
| 170 | ||
| 171 | $objectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 172 | $eventObjectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 173 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 174 | $innerServiceMock->method('createObjectStateGroup')->willReturn($objectStateGroup); |
|
| 175 | ||
| 176 | $traceableEventDispatcher->addListener(BeforeCreateObjectStateGroupEventInterface::class, function (BeforeCreateObjectStateGroupEventInterface $event) use ($eventObjectStateGroup) { |
|
| 177 | $event->setObjectStateGroup($eventObjectStateGroup); |
|
| 178 | $event->stopPropagation(); |
|
| 179 | }, 10); |
|
| 180 | ||
| 181 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 182 | $result = $service->createObjectStateGroup(...$parameters); |
|
| 183 | ||
| 184 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 185 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 186 | ||
| 187 | $this->assertSame($eventObjectStateGroup, $result); |
|
| 188 | $this->assertSame($calledListeners, [ |
|
| 189 | [BeforeCreateObjectStateGroupEventInterface::class, 10], |
|
| 190 | ]); |
|
| 191 | $this->assertSame($notCalledListeners, [ |
|
| 192 | [BeforeCreateObjectStateGroupEventInterface::class, 0], |
|
| 193 | [CreateObjectStateGroupEventInterface::class, 0], |
|
| 194 | ]); |
|
| 195 | } |
|
| 196 | ||
| 197 | public function testUpdateObjectStateEvents() |
|
| 198 | { |
|
| @@ 261-297 (lines=37) @@ | ||
| 258 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 259 | } |
|
| 260 | ||
| 261 | public function testUpdateObjectStateStopPropagationInBeforeEvents() |
|
| 262 | { |
|
| 263 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 264 | BeforeUpdateObjectStateEventInterface::class, |
|
| 265 | UpdateObjectStateEventInterface::class |
|
| 266 | ); |
|
| 267 | ||
| 268 | $parameters = [ |
|
| 269 | $this->createMock(ObjectState::class), |
|
| 270 | $this->createMock(ObjectStateUpdateStruct::class), |
|
| 271 | ]; |
|
| 272 | ||
| 273 | $updatedObjectState = $this->createMock(ObjectState::class); |
|
| 274 | $eventUpdatedObjectState = $this->createMock(ObjectState::class); |
|
| 275 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 276 | $innerServiceMock->method('updateObjectState')->willReturn($updatedObjectState); |
|
| 277 | ||
| 278 | $traceableEventDispatcher->addListener(BeforeUpdateObjectStateEventInterface::class, function (BeforeUpdateObjectStateEventInterface $event) use ($eventUpdatedObjectState) { |
|
| 279 | $event->setUpdatedObjectState($eventUpdatedObjectState); |
|
| 280 | $event->stopPropagation(); |
|
| 281 | }, 10); |
|
| 282 | ||
| 283 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 284 | $result = $service->updateObjectState(...$parameters); |
|
| 285 | ||
| 286 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 287 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 288 | ||
| 289 | $this->assertSame($eventUpdatedObjectState, $result); |
|
| 290 | $this->assertSame($calledListeners, [ |
|
| 291 | [BeforeUpdateObjectStateEventInterface::class, 10], |
|
| 292 | ]); |
|
| 293 | $this->assertSame($notCalledListeners, [ |
|
| 294 | [BeforeUpdateObjectStateEventInterface::class, 0], |
|
| 295 | [UpdateObjectStateEventInterface::class, 0], |
|
| 296 | ]); |
|
| 297 | } |
|
| 298 | ||
| 299 | public function testCreateObjectStateEvents() |
|
| 300 | { |
|
| @@ 363-399 (lines=37) @@ | ||
| 360 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 361 | } |
|
| 362 | ||
| 363 | public function testCreateObjectStateStopPropagationInBeforeEvents() |
|
| 364 | { |
|
| 365 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 366 | BeforeCreateObjectStateEventInterface::class, |
|
| 367 | CreateObjectStateEventInterface::class |
|
| 368 | ); |
|
| 369 | ||
| 370 | $parameters = [ |
|
| 371 | $this->createMock(ObjectStateGroup::class), |
|
| 372 | $this->createMock(ObjectStateCreateStruct::class), |
|
| 373 | ]; |
|
| 374 | ||
| 375 | $objectState = $this->createMock(ObjectState::class); |
|
| 376 | $eventObjectState = $this->createMock(ObjectState::class); |
|
| 377 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 378 | $innerServiceMock->method('createObjectState')->willReturn($objectState); |
|
| 379 | ||
| 380 | $traceableEventDispatcher->addListener(BeforeCreateObjectStateEventInterface::class, function (BeforeCreateObjectStateEventInterface $event) use ($eventObjectState) { |
|
| 381 | $event->setObjectState($eventObjectState); |
|
| 382 | $event->stopPropagation(); |
|
| 383 | }, 10); |
|
| 384 | ||
| 385 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 386 | $result = $service->createObjectState(...$parameters); |
|
| 387 | ||
| 388 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 389 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 390 | ||
| 391 | $this->assertSame($eventObjectState, $result); |
|
| 392 | $this->assertSame($calledListeners, [ |
|
| 393 | [BeforeCreateObjectStateEventInterface::class, 10], |
|
| 394 | ]); |
|
| 395 | $this->assertSame($notCalledListeners, [ |
|
| 396 | [BeforeCreateObjectStateEventInterface::class, 0], |
|
| 397 | [CreateObjectStateEventInterface::class, 0], |
|
| 398 | ]); |
|
| 399 | } |
|
| 400 | ||
| 401 | public function testUpdateObjectStateGroupEvents() |
|
| 402 | { |
|
| @@ 465-501 (lines=37) @@ | ||
| 462 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 463 | } |
|
| 464 | ||
| 465 | public function testUpdateObjectStateGroupStopPropagationInBeforeEvents() |
|
| 466 | { |
|
| 467 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 468 | BeforeUpdateObjectStateGroupEventInterface::class, |
|
| 469 | UpdateObjectStateGroupEventInterface::class |
|
| 470 | ); |
|
| 471 | ||
| 472 | $parameters = [ |
|
| 473 | $this->createMock(ObjectStateGroup::class), |
|
| 474 | $this->createMock(ObjectStateGroupUpdateStruct::class), |
|
| 475 | ]; |
|
| 476 | ||
| 477 | $updatedObjectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 478 | $eventUpdatedObjectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 479 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 480 | $innerServiceMock->method('updateObjectStateGroup')->willReturn($updatedObjectStateGroup); |
|
| 481 | ||
| 482 | $traceableEventDispatcher->addListener(BeforeUpdateObjectStateGroupEventInterface::class, function (BeforeUpdateObjectStateGroupEventInterface $event) use ($eventUpdatedObjectStateGroup) { |
|
| 483 | $event->setUpdatedObjectStateGroup($eventUpdatedObjectStateGroup); |
|
| 484 | $event->stopPropagation(); |
|
| 485 | }, 10); |
|
| 486 | ||
| 487 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 488 | $result = $service->updateObjectStateGroup(...$parameters); |
|
| 489 | ||
| 490 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 491 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 492 | ||
| 493 | $this->assertSame($eventUpdatedObjectStateGroup, $result); |
|
| 494 | $this->assertSame($calledListeners, [ |
|
| 495 | [BeforeUpdateObjectStateGroupEventInterface::class, 10], |
|
| 496 | ]); |
|
| 497 | $this->assertSame($notCalledListeners, [ |
|
| 498 | [BeforeUpdateObjectStateGroupEventInterface::class, 0], |
|
| 499 | [UpdateObjectStateGroupEventInterface::class, 0], |
|
| 500 | ]); |
|
| 501 | } |
|
| 502 | ||
| 503 | public function testSetPriorityOfObjectStateEvents() |
|
| 504 | { |
|
| @@ 183-219 (lines=37) @@ | ||
| 180 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 181 | } |
|
| 182 | ||
| 183 | public function testUpdateRoleStopPropagationInBeforeEvents() |
|
| 184 | { |
|
| 185 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 186 | BeforeUpdateRoleEventInterface::class, |
|
| 187 | UpdateRoleEventInterface::class |
|
| 188 | ); |
|
| 189 | ||
| 190 | $parameters = [ |
|
| 191 | $this->createMock(Role::class), |
|
| 192 | $this->createMock(RoleUpdateStruct::class), |
|
| 193 | ]; |
|
| 194 | ||
| 195 | $updatedRole = $this->createMock(Role::class); |
|
| 196 | $eventUpdatedRole = $this->createMock(Role::class); |
|
| 197 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 198 | $innerServiceMock->method('updateRole')->willReturn($updatedRole); |
|
| 199 | ||
| 200 | $traceableEventDispatcher->addListener(BeforeUpdateRoleEventInterface::class, function (BeforeUpdateRoleEventInterface $event) use ($eventUpdatedRole) { |
|
| 201 | $event->setUpdatedRole($eventUpdatedRole); |
|
| 202 | $event->stopPropagation(); |
|
| 203 | }, 10); |
|
| 204 | ||
| 205 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 206 | $result = $service->updateRole(...$parameters); |
|
| 207 | ||
| 208 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 209 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 210 | ||
| 211 | $this->assertSame($eventUpdatedRole, $result); |
|
| 212 | $this->assertSame($calledListeners, [ |
|
| 213 | [BeforeUpdateRoleEventInterface::class, 10], |
|
| 214 | ]); |
|
| 215 | $this->assertSame($notCalledListeners, [ |
|
| 216 | [BeforeUpdateRoleEventInterface::class, 0], |
|
| 217 | [UpdateRoleEventInterface::class, 0], |
|
| 218 | ]); |
|
| 219 | } |
|
| 220 | ||
| 221 | public function testPublishRoleDraftEvents() |
|
| 222 | { |
|
| @@ 403-439 (lines=37) @@ | ||
| 400 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 401 | } |
|
| 402 | ||
| 403 | public function testAddPolicyStopPropagationInBeforeEvents() |
|
| 404 | { |
|
| 405 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 406 | BeforeAddPolicyEventInterface::class, |
|
| 407 | AddPolicyEventInterface::class |
|
| 408 | ); |
|
| 409 | ||
| 410 | $parameters = [ |
|
| 411 | $this->createMock(Role::class), |
|
| 412 | $this->createMock(PolicyCreateStruct::class), |
|
| 413 | ]; |
|
| 414 | ||
| 415 | $updatedRole = $this->createMock(Role::class); |
|
| 416 | $eventUpdatedRole = $this->createMock(Role::class); |
|
| 417 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 418 | $innerServiceMock->method('addPolicy')->willReturn($updatedRole); |
|
| 419 | ||
| 420 | $traceableEventDispatcher->addListener(BeforeAddPolicyEventInterface::class, function (BeforeAddPolicyEventInterface $event) use ($eventUpdatedRole) { |
|
| 421 | $event->setUpdatedRole($eventUpdatedRole); |
|
| 422 | $event->stopPropagation(); |
|
| 423 | }, 10); |
|
| 424 | ||
| 425 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 426 | $result = $service->addPolicy(...$parameters); |
|
| 427 | ||
| 428 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 429 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 430 | ||
| 431 | $this->assertSame($eventUpdatedRole, $result); |
|
| 432 | $this->assertSame($calledListeners, [ |
|
| 433 | [BeforeAddPolicyEventInterface::class, 10], |
|
| 434 | ]); |
|
| 435 | $this->assertSame($notCalledListeners, [ |
|
| 436 | [AddPolicyEventInterface::class, 0], |
|
| 437 | [BeforeAddPolicyEventInterface::class, 0], |
|
| 438 | ]); |
|
| 439 | } |
|
| 440 | ||
| 441 | public function testUpdateRoleDraftEvents() |
|
| 442 | { |
|
| @@ 505-541 (lines=37) @@ | ||
| 502 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 503 | } |
|
| 504 | ||
| 505 | public function testUpdateRoleDraftStopPropagationInBeforeEvents() |
|
| 506 | { |
|
| 507 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 508 | BeforeUpdateRoleDraftEventInterface::class, |
|
| 509 | UpdateRoleDraftEventInterface::class |
|
| 510 | ); |
|
| 511 | ||
| 512 | $parameters = [ |
|
| 513 | $this->createMock(RoleDraft::class), |
|
| 514 | $this->createMock(RoleUpdateStruct::class), |
|
| 515 | ]; |
|
| 516 | ||
| 517 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 518 | $eventUpdatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 519 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 520 | $innerServiceMock->method('updateRoleDraft')->willReturn($updatedRoleDraft); |
|
| 521 | ||
| 522 | $traceableEventDispatcher->addListener(BeforeUpdateRoleDraftEventInterface::class, function (BeforeUpdateRoleDraftEventInterface $event) use ($eventUpdatedRoleDraft) { |
|
| 523 | $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); |
|
| 524 | $event->stopPropagation(); |
|
| 525 | }, 10); |
|
| 526 | ||
| 527 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 528 | $result = $service->updateRoleDraft(...$parameters); |
|
| 529 | ||
| 530 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 531 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 532 | ||
| 533 | $this->assertSame($eventUpdatedRoleDraft, $result); |
|
| 534 | $this->assertSame($calledListeners, [ |
|
| 535 | [BeforeUpdateRoleDraftEventInterface::class, 10], |
|
| 536 | ]); |
|
| 537 | $this->assertSame($notCalledListeners, [ |
|
| 538 | [BeforeUpdateRoleDraftEventInterface::class, 0], |
|
| 539 | [UpdateRoleDraftEventInterface::class, 0], |
|
| 540 | ]); |
|
| 541 | } |
|
| 542 | ||
| 543 | public function testAssignRoleToUserGroupEvents() |
|
| 544 | { |
|
| @@ 830-865 (lines=36) @@ | ||
| 827 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 828 | } |
|
| 829 | ||
| 830 | public function testCreateRoleStopPropagationInBeforeEvents() |
|
| 831 | { |
|
| 832 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 833 | BeforeCreateRoleEventInterface::class, |
|
| 834 | CreateRoleEventInterface::class |
|
| 835 | ); |
|
| 836 | ||
| 837 | $parameters = [ |
|
| 838 | $this->createMock(RoleCreateStruct::class), |
|
| 839 | ]; |
|
| 840 | ||
| 841 | $roleDraft = $this->createMock(RoleDraft::class); |
|
| 842 | $eventRoleDraft = $this->createMock(RoleDraft::class); |
|
| 843 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 844 | $innerServiceMock->method('createRole')->willReturn($roleDraft); |
|
| 845 | ||
| 846 | $traceableEventDispatcher->addListener(BeforeCreateRoleEventInterface::class, function (BeforeCreateRoleEventInterface $event) use ($eventRoleDraft) { |
|
| 847 | $event->setRoleDraft($eventRoleDraft); |
|
| 848 | $event->stopPropagation(); |
|
| 849 | }, 10); |
|
| 850 | ||
| 851 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 852 | $result = $service->createRole(...$parameters); |
|
| 853 | ||
| 854 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 855 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 856 | ||
| 857 | $this->assertSame($eventRoleDraft, $result); |
|
| 858 | $this->assertSame($calledListeners, [ |
|
| 859 | [BeforeCreateRoleEventInterface::class, 10], |
|
| 860 | ]); |
|
| 861 | $this->assertSame($notCalledListeners, [ |
|
| 862 | [BeforeCreateRoleEventInterface::class, 0], |
|
| 863 | [CreateRoleEventInterface::class, 0], |
|
| 864 | ]); |
|
| 865 | } |
|
| 866 | ||
| 867 | public function testRemovePolicyByRoleDraftEvents() |
|
| 868 | { |
|
| @@ 931-967 (lines=37) @@ | ||
| 928 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 929 | } |
|
| 930 | ||
| 931 | public function testRemovePolicyByRoleDraftStopPropagationInBeforeEvents() |
|
| 932 | { |
|
| 933 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 934 | BeforeRemovePolicyByRoleDraftEventInterface::class, |
|
| 935 | RemovePolicyByRoleDraftEventInterface::class |
|
| 936 | ); |
|
| 937 | ||
| 938 | $parameters = [ |
|
| 939 | $this->createMock(RoleDraft::class), |
|
| 940 | $this->createMock(PolicyDraft::class), |
|
| 941 | ]; |
|
| 942 | ||
| 943 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 944 | $eventUpdatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 945 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 946 | $innerServiceMock->method('removePolicyByRoleDraft')->willReturn($updatedRoleDraft); |
|
| 947 | ||
| 948 | $traceableEventDispatcher->addListener(BeforeRemovePolicyByRoleDraftEventInterface::class, function (BeforeRemovePolicyByRoleDraftEventInterface $event) use ($eventUpdatedRoleDraft) { |
|
| 949 | $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); |
|
| 950 | $event->stopPropagation(); |
|
| 951 | }, 10); |
|
| 952 | ||
| 953 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 954 | $result = $service->removePolicyByRoleDraft(...$parameters); |
|
| 955 | ||
| 956 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 957 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 958 | ||
| 959 | $this->assertSame($eventUpdatedRoleDraft, $result); |
|
| 960 | $this->assertSame($calledListeners, [ |
|
| 961 | [BeforeRemovePolicyByRoleDraftEventInterface::class, 10], |
|
| 962 | ]); |
|
| 963 | $this->assertSame($notCalledListeners, [ |
|
| 964 | [BeforeRemovePolicyByRoleDraftEventInterface::class, 0], |
|
| 965 | [RemovePolicyByRoleDraftEventInterface::class, 0], |
|
| 966 | ]); |
|
| 967 | } |
|
| 968 | ||
| 969 | public function testAddPolicyByRoleDraftEvents() |
|
| 970 | { |
|
| @@ 1033-1069 (lines=37) @@ | ||
| 1030 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1031 | } |
|
| 1032 | ||
| 1033 | public function testAddPolicyByRoleDraftStopPropagationInBeforeEvents() |
|
| 1034 | { |
|
| 1035 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1036 | BeforeAddPolicyByRoleDraftEventInterface::class, |
|
| 1037 | AddPolicyByRoleDraftEventInterface::class |
|
| 1038 | ); |
|
| 1039 | ||
| 1040 | $parameters = [ |
|
| 1041 | $this->createMock(RoleDraft::class), |
|
| 1042 | $this->createMock(PolicyCreateStruct::class), |
|
| 1043 | ]; |
|
| 1044 | ||
| 1045 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 1046 | $eventUpdatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 1047 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 1048 | $innerServiceMock->method('addPolicyByRoleDraft')->willReturn($updatedRoleDraft); |
|
| 1049 | ||
| 1050 | $traceableEventDispatcher->addListener(BeforeAddPolicyByRoleDraftEventInterface::class, function (BeforeAddPolicyByRoleDraftEventInterface $event) use ($eventUpdatedRoleDraft) { |
|
| 1051 | $event->setUpdatedRoleDraft($eventUpdatedRoleDraft); |
|
| 1052 | $event->stopPropagation(); |
|
| 1053 | }, 10); |
|
| 1054 | ||
| 1055 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 1056 | $result = $service->addPolicyByRoleDraft(...$parameters); |
|
| 1057 | ||
| 1058 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1059 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 1060 | ||
| 1061 | $this->assertSame($eventUpdatedRoleDraft, $result); |
|
| 1062 | $this->assertSame($calledListeners, [ |
|
| 1063 | [BeforeAddPolicyByRoleDraftEventInterface::class, 10], |
|
| 1064 | ]); |
|
| 1065 | $this->assertSame($notCalledListeners, [ |
|
| 1066 | [AddPolicyByRoleDraftEventInterface::class, 0], |
|
| 1067 | [BeforeAddPolicyByRoleDraftEventInterface::class, 0], |
|
| 1068 | ]); |
|
| 1069 | } |
|
| 1070 | ||
| 1071 | public function testDeleteRoleEvents() |
|
| 1072 | { |
|
| @@ 1304-1339 (lines=36) @@ | ||
| 1301 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1302 | } |
|
| 1303 | ||
| 1304 | public function testCreateRoleDraftStopPropagationInBeforeEvents() |
|
| 1305 | { |
|
| 1306 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1307 | BeforeCreateRoleDraftEventInterface::class, |
|
| 1308 | CreateRoleDraftEventInterface::class |
|
| 1309 | ); |
|
| 1310 | ||
| 1311 | $parameters = [ |
|
| 1312 | $this->createMock(Role::class), |
|
| 1313 | ]; |
|
| 1314 | ||
| 1315 | $roleDraft = $this->createMock(RoleDraft::class); |
|
| 1316 | $eventRoleDraft = $this->createMock(RoleDraft::class); |
|
| 1317 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 1318 | $innerServiceMock->method('createRoleDraft')->willReturn($roleDraft); |
|
| 1319 | ||
| 1320 | $traceableEventDispatcher->addListener(BeforeCreateRoleDraftEventInterface::class, function (BeforeCreateRoleDraftEventInterface $event) use ($eventRoleDraft) { |
|
| 1321 | $event->setRoleDraft($eventRoleDraft); |
|
| 1322 | $event->stopPropagation(); |
|
| 1323 | }, 10); |
|
| 1324 | ||
| 1325 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 1326 | $result = $service->createRoleDraft(...$parameters); |
|
| 1327 | ||
| 1328 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1329 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 1330 | ||
| 1331 | $this->assertSame($eventRoleDraft, $result); |
|
| 1332 | $this->assertSame($calledListeners, [ |
|
| 1333 | [BeforeCreateRoleDraftEventInterface::class, 10], |
|
| 1334 | ]); |
|
| 1335 | $this->assertSame($notCalledListeners, [ |
|
| 1336 | [BeforeCreateRoleDraftEventInterface::class, 0], |
|
| 1337 | [CreateRoleDraftEventInterface::class, 0], |
|
| 1338 | ]); |
|
| 1339 | } |
|
| 1340 | ||
| 1341 | public function testUpdatePolicyEvents() |
|
| 1342 | { |
|
| @@ 1405-1441 (lines=37) @@ | ||
| 1402 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1403 | } |
|
| 1404 | ||
| 1405 | public function testUpdatePolicyStopPropagationInBeforeEvents() |
|
| 1406 | { |
|
| 1407 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1408 | BeforeUpdatePolicyEventInterface::class, |
|
| 1409 | UpdatePolicyEventInterface::class |
|
| 1410 | ); |
|
| 1411 | ||
| 1412 | $parameters = [ |
|
| 1413 | $this->createMock(Policy::class), |
|
| 1414 | $this->createMock(PolicyUpdateStruct::class), |
|
| 1415 | ]; |
|
| 1416 | ||
| 1417 | $updatedPolicy = $this->createMock(Policy::class); |
|
| 1418 | $eventUpdatedPolicy = $this->createMock(Policy::class); |
|
| 1419 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 1420 | $innerServiceMock->method('updatePolicy')->willReturn($updatedPolicy); |
|
| 1421 | ||
| 1422 | $traceableEventDispatcher->addListener(BeforeUpdatePolicyEventInterface::class, function (BeforeUpdatePolicyEventInterface $event) use ($eventUpdatedPolicy) { |
|
| 1423 | $event->setUpdatedPolicy($eventUpdatedPolicy); |
|
| 1424 | $event->stopPropagation(); |
|
| 1425 | }, 10); |
|
| 1426 | ||
| 1427 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 1428 | $result = $service->updatePolicy(...$parameters); |
|
| 1429 | ||
| 1430 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1431 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 1432 | ||
| 1433 | $this->assertSame($eventUpdatedPolicy, $result); |
|
| 1434 | $this->assertSame($calledListeners, [ |
|
| 1435 | [BeforeUpdatePolicyEventInterface::class, 10], |
|
| 1436 | ]); |
|
| 1437 | $this->assertSame($notCalledListeners, [ |
|
| 1438 | [BeforeUpdatePolicyEventInterface::class, 0], |
|
| 1439 | [UpdatePolicyEventInterface::class, 0], |
|
| 1440 | ]); |
|
| 1441 | } |
|
| 1442 | ||
| 1443 | public function testUnassignRoleFromUserGroupEvents() |
|
| 1444 | { |
|
| @@ 152-188 (lines=37) @@ | ||
| 149 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 150 | } |
|
| 151 | ||
| 152 | public function testUpdateSectionStopPropagationInBeforeEvents() |
|
| 153 | { |
|
| 154 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 155 | BeforeUpdateSectionEventInterface::class, |
|
| 156 | UpdateSectionEventInterface::class |
|
| 157 | ); |
|
| 158 | ||
| 159 | $parameters = [ |
|
| 160 | $this->createMock(Section::class), |
|
| 161 | $this->createMock(SectionUpdateStruct::class), |
|
| 162 | ]; |
|
| 163 | ||
| 164 | $updatedSection = $this->createMock(Section::class); |
|
| 165 | $eventUpdatedSection = $this->createMock(Section::class); |
|
| 166 | $innerServiceMock = $this->createMock(SectionServiceInterface::class); |
|
| 167 | $innerServiceMock->method('updateSection')->willReturn($updatedSection); |
|
| 168 | ||
| 169 | $traceableEventDispatcher->addListener(BeforeUpdateSectionEventInterface::class, function (BeforeUpdateSectionEventInterface $event) use ($eventUpdatedSection) { |
|
| 170 | $event->setUpdatedSection($eventUpdatedSection); |
|
| 171 | $event->stopPropagation(); |
|
| 172 | }, 10); |
|
| 173 | ||
| 174 | $service = new SectionService($innerServiceMock, $traceableEventDispatcher); |
|
| 175 | $result = $service->updateSection(...$parameters); |
|
| 176 | ||
| 177 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 178 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 179 | ||
| 180 | $this->assertSame($eventUpdatedSection, $result); |
|
| 181 | $this->assertSame($calledListeners, [ |
|
| 182 | [BeforeUpdateSectionEventInterface::class, 10], |
|
| 183 | ]); |
|
| 184 | $this->assertSame($notCalledListeners, [ |
|
| 185 | [BeforeUpdateSectionEventInterface::class, 0], |
|
| 186 | [UpdateSectionEventInterface::class, 0], |
|
| 187 | ]); |
|
| 188 | } |
|
| 189 | ||
| 190 | public function testAssignSectionToSubtreeEvents() |
|
| 191 | { |
|
| @@ 368-403 (lines=36) @@ | ||
| 365 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 366 | } |
|
| 367 | ||
| 368 | public function testCreateSectionStopPropagationInBeforeEvents() |
|
| 369 | { |
|
| 370 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 371 | BeforeCreateSectionEventInterface::class, |
|
| 372 | CreateSectionEventInterface::class |
|
| 373 | ); |
|
| 374 | ||
| 375 | $parameters = [ |
|
| 376 | $this->createMock(SectionCreateStruct::class), |
|
| 377 | ]; |
|
| 378 | ||
| 379 | $section = $this->createMock(Section::class); |
|
| 380 | $eventSection = $this->createMock(Section::class); |
|
| 381 | $innerServiceMock = $this->createMock(SectionServiceInterface::class); |
|
| 382 | $innerServiceMock->method('createSection')->willReturn($section); |
|
| 383 | ||
| 384 | $traceableEventDispatcher->addListener(BeforeCreateSectionEventInterface::class, function (BeforeCreateSectionEventInterface $event) use ($eventSection) { |
|
| 385 | $event->setSection($eventSection); |
|
| 386 | $event->stopPropagation(); |
|
| 387 | }, 10); |
|
| 388 | ||
| 389 | $service = new SectionService($innerServiceMock, $traceableEventDispatcher); |
|
| 390 | $result = $service->createSection(...$parameters); |
|
| 391 | ||
| 392 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 393 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 394 | ||
| 395 | $this->assertSame($eventSection, $result); |
|
| 396 | $this->assertSame($calledListeners, [ |
|
| 397 | [BeforeCreateSectionEventInterface::class, 10], |
|
| 398 | ]); |
|
| 399 | $this->assertSame($notCalledListeners, [ |
|
| 400 | [BeforeCreateSectionEventInterface::class, 0], |
|
| 401 | [CreateSectionEventInterface::class, 0], |
|
| 402 | ]); |
|
| 403 | } |
|
| 404 | } |
|
| 405 | ||
| @@ 86-120 (lines=35) @@ | ||
| 83 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 84 | } |
|
| 85 | ||
| 86 | public function testEmptyTrashStopPropagationInBeforeEvents() |
|
| 87 | { |
|
| 88 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 89 | BeforeEmptyTrashEventInterface::class, |
|
| 90 | EmptyTrashEventInterface::class |
|
| 91 | ); |
|
| 92 | ||
| 93 | $parameters = [ |
|
| 94 | ]; |
|
| 95 | ||
| 96 | $resultList = $this->createMock(TrashItemDeleteResultList::class); |
|
| 97 | $eventResultList = $this->createMock(TrashItemDeleteResultList::class); |
|
| 98 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 99 | $innerServiceMock->method('emptyTrash')->willReturn($resultList); |
|
| 100 | ||
| 101 | $traceableEventDispatcher->addListener(BeforeEmptyTrashEventInterface::class, function (BeforeEmptyTrashEventInterface $event) use ($eventResultList) { |
|
| 102 | $event->setResultList($eventResultList); |
|
| 103 | $event->stopPropagation(); |
|
| 104 | }, 10); |
|
| 105 | ||
| 106 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 107 | $result = $service->emptyTrash(...$parameters); |
|
| 108 | ||
| 109 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 110 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 111 | ||
| 112 | $this->assertSame($eventResultList, $result); |
|
| 113 | $this->assertSame($calledListeners, [ |
|
| 114 | [BeforeEmptyTrashEventInterface::class, 10], |
|
| 115 | ]); |
|
| 116 | $this->assertSame($notCalledListeners, [ |
|
| 117 | [BeforeEmptyTrashEventInterface::class, 0], |
|
| 118 | [EmptyTrashEventInterface::class, 0], |
|
| 119 | ]); |
|
| 120 | } |
|
| 121 | ||
| 122 | public function testTrashEvents() |
|
| 123 | { |
|
| @@ 184-219 (lines=36) @@ | ||
| 181 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 182 | } |
|
| 183 | ||
| 184 | public function testTrashStopPropagationInBeforeEvents() |
|
| 185 | { |
|
| 186 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 187 | BeforeTrashEventInterface::class, |
|
| 188 | TrashEventInterface::class |
|
| 189 | ); |
|
| 190 | ||
| 191 | $parameters = [ |
|
| 192 | $this->createMock(Location::class), |
|
| 193 | ]; |
|
| 194 | ||
| 195 | $trashItem = $this->createMock(TrashItem::class); |
|
| 196 | $eventTrashItem = $this->createMock(TrashItem::class); |
|
| 197 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 198 | $innerServiceMock->method('trash')->willReturn($trashItem); |
|
| 199 | ||
| 200 | $traceableEventDispatcher->addListener(BeforeTrashEventInterface::class, function (BeforeTrashEventInterface $event) use ($eventTrashItem) { |
|
| 201 | $event->setResult($eventTrashItem); |
|
| 202 | $event->stopPropagation(); |
|
| 203 | }, 10); |
|
| 204 | ||
| 205 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 206 | $result = $service->trash(...$parameters); |
|
| 207 | ||
| 208 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 209 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 210 | ||
| 211 | $this->assertSame($eventTrashItem, $result); |
|
| 212 | $this->assertSame($calledListeners, [ |
|
| 213 | [BeforeTrashEventInterface::class, 10], |
|
| 214 | ]); |
|
| 215 | $this->assertSame($notCalledListeners, [ |
|
| 216 | [BeforeTrashEventInterface::class, 0], |
|
| 217 | [TrashEventInterface::class, 0], |
|
| 218 | ]); |
|
| 219 | } |
|
| 220 | ||
| 221 | public function testRecoverEvents() |
|
| 222 | { |
|
| @@ 285-321 (lines=37) @@ | ||
| 282 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 283 | } |
|
| 284 | ||
| 285 | public function testRecoverStopPropagationInBeforeEvents() |
|
| 286 | { |
|
| 287 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 288 | BeforeRecoverEventInterface::class, |
|
| 289 | RecoverEventInterface::class |
|
| 290 | ); |
|
| 291 | ||
| 292 | $parameters = [ |
|
| 293 | $this->createMock(TrashItem::class), |
|
| 294 | $this->createMock(Location::class), |
|
| 295 | ]; |
|
| 296 | ||
| 297 | $location = $this->createMock(Location::class); |
|
| 298 | $eventLocation = $this->createMock(Location::class); |
|
| 299 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 300 | $innerServiceMock->method('recover')->willReturn($location); |
|
| 301 | ||
| 302 | $traceableEventDispatcher->addListener(BeforeRecoverEventInterface::class, function (BeforeRecoverEventInterface $event) use ($eventLocation) { |
|
| 303 | $event->setLocation($eventLocation); |
|
| 304 | $event->stopPropagation(); |
|
| 305 | }, 10); |
|
| 306 | ||
| 307 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 308 | $result = $service->recover(...$parameters); |
|
| 309 | ||
| 310 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 311 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 312 | ||
| 313 | $this->assertSame($eventLocation, $result); |
|
| 314 | $this->assertSame($calledListeners, [ |
|
| 315 | [BeforeRecoverEventInterface::class, 10], |
|
| 316 | ]); |
|
| 317 | $this->assertSame($notCalledListeners, [ |
|
| 318 | [BeforeRecoverEventInterface::class, 0], |
|
| 319 | [RecoverEventInterface::class, 0], |
|
| 320 | ]); |
|
| 321 | } |
|
| 322 | ||
| 323 | public function testDeleteTrashItemEvents() |
|
| 324 | { |
|
| @@ 385-420 (lines=36) @@ | ||
| 382 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 383 | } |
|
| 384 | ||
| 385 | public function testDeleteTrashItemStopPropagationInBeforeEvents() |
|
| 386 | { |
|
| 387 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 388 | BeforeDeleteTrashItemEventInterface::class, |
|
| 389 | DeleteTrashItemEventInterface::class |
|
| 390 | ); |
|
| 391 | ||
| 392 | $parameters = [ |
|
| 393 | $this->createMock(TrashItem::class), |
|
| 394 | ]; |
|
| 395 | ||
| 396 | $result = $this->createMock(TrashItemDeleteResult::class); |
|
| 397 | $eventResult = $this->createMock(TrashItemDeleteResult::class); |
|
| 398 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 399 | $innerServiceMock->method('deleteTrashItem')->willReturn($result); |
|
| 400 | ||
| 401 | $traceableEventDispatcher->addListener(BeforeDeleteTrashItemEventInterface::class, function (BeforeDeleteTrashItemEventInterface $event) use ($eventResult) { |
|
| 402 | $event->setResult($eventResult); |
|
| 403 | $event->stopPropagation(); |
|
| 404 | }, 10); |
|
| 405 | ||
| 406 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 407 | $result = $service->deleteTrashItem(...$parameters); |
|
| 408 | ||
| 409 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 410 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 411 | ||
| 412 | $this->assertSame($eventResult, $result); |
|
| 413 | $this->assertSame($calledListeners, [ |
|
| 414 | [BeforeDeleteTrashItemEventInterface::class, 10], |
|
| 415 | ]); |
|
| 416 | $this->assertSame($notCalledListeners, [ |
|
| 417 | [BeforeDeleteTrashItemEventInterface::class, 0], |
|
| 418 | [DeleteTrashItemEventInterface::class, 0], |
|
| 419 | ]); |
|
| 420 | } |
|
| 421 | } |
|
| 422 | ||
| @@ 82-118 (lines=37) @@ | ||
| 79 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 80 | } |
|
| 81 | ||
| 82 | public function testUpdateUrlStopPropagationInBeforeEvents() |
|
| 83 | { |
|
| 84 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 85 | BeforeUpdateUrlEventInterface::class, |
|
| 86 | UpdateUrlEventInterface::class |
|
| 87 | ); |
|
| 88 | ||
| 89 | $parameters = [ |
|
| 90 | $this->createMock(URL::class), |
|
| 91 | $this->createMock(URLUpdateStruct::class), |
|
| 92 | ]; |
|
| 93 | ||
| 94 | $updatedUrl = $this->createMock(URL::class); |
|
| 95 | $eventUpdatedUrl = $this->createMock(URL::class); |
|
| 96 | $innerServiceMock = $this->createMock(URLServiceInterface::class); |
|
| 97 | $innerServiceMock->method('updateUrl')->willReturn($updatedUrl); |
|
| 98 | ||
| 99 | $traceableEventDispatcher->addListener(BeforeUpdateUrlEventInterface::class, function (BeforeUpdateUrlEventInterface $event) use ($eventUpdatedUrl) { |
|
| 100 | $event->setUpdatedUrl($eventUpdatedUrl); |
|
| 101 | $event->stopPropagation(); |
|
| 102 | }, 10); |
|
| 103 | ||
| 104 | $service = new URLService($innerServiceMock, $traceableEventDispatcher); |
|
| 105 | $result = $service->updateUrl(...$parameters); |
|
| 106 | ||
| 107 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 108 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 109 | ||
| 110 | $this->assertSame($eventUpdatedUrl, $result); |
|
| 111 | $this->assertSame($calledListeners, [ |
|
| 112 | [BeforeUpdateUrlEventInterface::class, 10], |
|
| 113 | ]); |
|
| 114 | $this->assertSame($notCalledListeners, [ |
|
| 115 | [BeforeUpdateUrlEventInterface::class, 0], |
|
| 116 | [UpdateUrlEventInterface::class, 0], |
|
| 117 | ]); |
|
| 118 | } |
|
| 119 | } |
|
| 120 | ||
| @@ 246-281 (lines=36) @@ | ||
| 243 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 244 | } |
|
| 245 | ||
| 246 | public function testTranslateStopPropagationInBeforeEvents() |
|
| 247 | { |
|
| 248 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 249 | BeforeTranslateEventInterface::class, |
|
| 250 | TranslateEventInterface::class |
|
| 251 | ); |
|
| 252 | ||
| 253 | $parameters = [ |
|
| 254 | 'random_value_5cff79c316d3f9.73226122', |
|
| 255 | ]; |
|
| 256 | ||
| 257 | $result = $this->createMock(URLWildcardTranslationResult::class); |
|
| 258 | $eventResult = $this->createMock(URLWildcardTranslationResult::class); |
|
| 259 | $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class); |
|
| 260 | $innerServiceMock->method('translate')->willReturn($result); |
|
| 261 | ||
| 262 | $traceableEventDispatcher->addListener(BeforeTranslateEventInterface::class, function (BeforeTranslateEventInterface $event) use ($eventResult) { |
|
| 263 | $event->setResult($eventResult); |
|
| 264 | $event->stopPropagation(); |
|
| 265 | }, 10); |
|
| 266 | ||
| 267 | $service = new URLWildcardService($innerServiceMock, $traceableEventDispatcher); |
|
| 268 | $result = $service->translate(...$parameters); |
|
| 269 | ||
| 270 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 271 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 272 | ||
| 273 | $this->assertSame($eventResult, $result); |
|
| 274 | $this->assertSame($calledListeners, [ |
|
| 275 | [BeforeTranslateEventInterface::class, 10], |
|
| 276 | ]); |
|
| 277 | $this->assertSame($notCalledListeners, [ |
|
| 278 | [BeforeTranslateEventInterface::class, 0], |
|
| 279 | [TranslateEventInterface::class, 0], |
|
| 280 | ]); |
|
| 281 | } |
|
| 282 | } |
|
| 283 | ||
| @@ 105-141 (lines=37) @@ | ||
| 102 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 103 | } |
|
| 104 | ||
| 105 | public function testUpdateUserGroupStopPropagationInBeforeEvents() |
|
| 106 | { |
|
| 107 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 108 | BeforeUpdateUserGroupEventInterface::class, |
|
| 109 | UpdateUserGroupEventInterface::class |
|
| 110 | ); |
|
| 111 | ||
| 112 | $parameters = [ |
|
| 113 | $this->createMock(UserGroup::class), |
|
| 114 | $this->createMock(UserGroupUpdateStruct::class), |
|
| 115 | ]; |
|
| 116 | ||
| 117 | $updatedUserGroup = $this->createMock(UserGroup::class); |
|
| 118 | $eventUpdatedUserGroup = $this->createMock(UserGroup::class); |
|
| 119 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 120 | $innerServiceMock->method('updateUserGroup')->willReturn($updatedUserGroup); |
|
| 121 | ||
| 122 | $traceableEventDispatcher->addListener(BeforeUpdateUserGroupEventInterface::class, function (BeforeUpdateUserGroupEventInterface $event) use ($eventUpdatedUserGroup) { |
|
| 123 | $event->setUpdatedUserGroup($eventUpdatedUserGroup); |
|
| 124 | $event->stopPropagation(); |
|
| 125 | }, 10); |
|
| 126 | ||
| 127 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 128 | $result = $service->updateUserGroup(...$parameters); |
|
| 129 | ||
| 130 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 131 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 132 | ||
| 133 | $this->assertSame($eventUpdatedUserGroup, $result); |
|
| 134 | $this->assertSame($calledListeners, [ |
|
| 135 | [BeforeUpdateUserGroupEventInterface::class, 10], |
|
| 136 | ]); |
|
| 137 | $this->assertSame($notCalledListeners, [ |
|
| 138 | [BeforeUpdateUserGroupEventInterface::class, 0], |
|
| 139 | [UpdateUserGroupEventInterface::class, 0], |
|
| 140 | ]); |
|
| 141 | } |
|
| 142 | ||
| 143 | public function testUpdateUserEvents() |
|
| 144 | { |
|
| @@ 207-243 (lines=37) @@ | ||
| 204 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 205 | } |
|
| 206 | ||
| 207 | public function testUpdateUserStopPropagationInBeforeEvents() |
|
| 208 | { |
|
| 209 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 210 | BeforeUpdateUserEventInterface::class, |
|
| 211 | UpdateUserEventInterface::class |
|
| 212 | ); |
|
| 213 | ||
| 214 | $parameters = [ |
|
| 215 | $this->createMock(User::class), |
|
| 216 | $this->createMock(UserUpdateStruct::class), |
|
| 217 | ]; |
|
| 218 | ||
| 219 | $updatedUser = $this->createMock(User::class); |
|
| 220 | $eventUpdatedUser = $this->createMock(User::class); |
|
| 221 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 222 | $innerServiceMock->method('updateUser')->willReturn($updatedUser); |
|
| 223 | ||
| 224 | $traceableEventDispatcher->addListener(BeforeUpdateUserEventInterface::class, function (BeforeUpdateUserEventInterface $event) use ($eventUpdatedUser) { |
|
| 225 | $event->setUpdatedUser($eventUpdatedUser); |
|
| 226 | $event->stopPropagation(); |
|
| 227 | }, 10); |
|
| 228 | ||
| 229 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 230 | $result = $service->updateUser(...$parameters); |
|
| 231 | ||
| 232 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 233 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 234 | ||
| 235 | $this->assertSame($eventUpdatedUser, $result); |
|
| 236 | $this->assertSame($calledListeners, [ |
|
| 237 | [BeforeUpdateUserEventInterface::class, 10], |
|
| 238 | ]); |
|
| 239 | $this->assertSame($notCalledListeners, [ |
|
| 240 | [BeforeUpdateUserEventInterface::class, 0], |
|
| 241 | [UpdateUserEventInterface::class, 0], |
|
| 242 | ]); |
|
| 243 | } |
|
| 244 | ||
| 245 | public function testUnAssignUserFromUserGroupEvents() |
|
| 246 | { |
|
| @@ 684-720 (lines=37) @@ | ||
| 681 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 682 | } |
|
| 683 | ||
| 684 | public function testCreateUserStopPropagationInBeforeEvents() |
|
| 685 | { |
|
| 686 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 687 | BeforeCreateUserEventInterface::class, |
|
| 688 | CreateUserEventInterface::class |
|
| 689 | ); |
|
| 690 | ||
| 691 | $parameters = [ |
|
| 692 | $this->createMock(UserCreateStruct::class), |
|
| 693 | [], |
|
| 694 | ]; |
|
| 695 | ||
| 696 | $user = $this->createMock(User::class); |
|
| 697 | $eventUser = $this->createMock(User::class); |
|
| 698 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 699 | $innerServiceMock->method('createUser')->willReturn($user); |
|
| 700 | ||
| 701 | $traceableEventDispatcher->addListener(BeforeCreateUserEventInterface::class, function (BeforeCreateUserEventInterface $event) use ($eventUser) { |
|
| 702 | $event->setUser($eventUser); |
|
| 703 | $event->stopPropagation(); |
|
| 704 | }, 10); |
|
| 705 | ||
| 706 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 707 | $result = $service->createUser(...$parameters); |
|
| 708 | ||
| 709 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 710 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 711 | ||
| 712 | $this->assertSame($eventUser, $result); |
|
| 713 | $this->assertSame($calledListeners, [ |
|
| 714 | [BeforeCreateUserEventInterface::class, 10], |
|
| 715 | ]); |
|
| 716 | $this->assertSame($notCalledListeners, [ |
|
| 717 | [BeforeCreateUserEventInterface::class, 0], |
|
| 718 | [CreateUserEventInterface::class, 0], |
|
| 719 | ]); |
|
| 720 | } |
|
| 721 | ||
| 722 | public function testCreateUserGroupEvents() |
|
| 723 | { |
|
| @@ 786-822 (lines=37) @@ | ||
| 783 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 784 | } |
|
| 785 | ||
| 786 | public function testCreateUserGroupStopPropagationInBeforeEvents() |
|
| 787 | { |
|
| 788 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 789 | BeforeCreateUserGroupEventInterface::class, |
|
| 790 | CreateUserGroupEventInterface::class |
|
| 791 | ); |
|
| 792 | ||
| 793 | $parameters = [ |
|
| 794 | $this->createMock(UserGroupCreateStruct::class), |
|
| 795 | $this->createMock(UserGroup::class), |
|
| 796 | ]; |
|
| 797 | ||
| 798 | $userGroup = $this->createMock(UserGroup::class); |
|
| 799 | $eventUserGroup = $this->createMock(UserGroup::class); |
|
| 800 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 801 | $innerServiceMock->method('createUserGroup')->willReturn($userGroup); |
|
| 802 | ||
| 803 | $traceableEventDispatcher->addListener(BeforeCreateUserGroupEventInterface::class, function (BeforeCreateUserGroupEventInterface $event) use ($eventUserGroup) { |
|
| 804 | $event->setUserGroup($eventUserGroup); |
|
| 805 | $event->stopPropagation(); |
|
| 806 | }, 10); |
|
| 807 | ||
| 808 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 809 | $result = $service->createUserGroup(...$parameters); |
|
| 810 | ||
| 811 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 812 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 813 | ||
| 814 | $this->assertSame($eventUserGroup, $result); |
|
| 815 | $this->assertSame($calledListeners, [ |
|
| 816 | [BeforeCreateUserGroupEventInterface::class, 10], |
|
| 817 | ]); |
|
| 818 | $this->assertSame($notCalledListeners, [ |
|
| 819 | [BeforeCreateUserGroupEventInterface::class, 0], |
|
| 820 | [CreateUserGroupEventInterface::class, 0], |
|
| 821 | ]); |
|
| 822 | } |
|
| 823 | ||
| 824 | public function testUpdateUserTokenEvents() |
|
| 825 | { |
|
| @@ 888-924 (lines=37) @@ | ||
| 885 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 886 | } |
|
| 887 | ||
| 888 | public function testUpdateUserTokenStopPropagationInBeforeEvents() |
|
| 889 | { |
|
| 890 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 891 | BeforeUpdateUserTokenEventInterface::class, |
|
| 892 | UpdateUserTokenEventInterface::class |
|
| 893 | ); |
|
| 894 | ||
| 895 | $parameters = [ |
|
| 896 | $this->createMock(User::class), |
|
| 897 | $this->createMock(UserTokenUpdateStruct::class), |
|
| 898 | ]; |
|
| 899 | ||
| 900 | $updatedUser = $this->createMock(User::class); |
|
| 901 | $eventUpdatedUser = $this->createMock(User::class); |
|
| 902 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 903 | $innerServiceMock->method('updateUserToken')->willReturn($updatedUser); |
|
| 904 | ||
| 905 | $traceableEventDispatcher->addListener(BeforeUpdateUserTokenEventInterface::class, function (BeforeUpdateUserTokenEventInterface $event) use ($eventUpdatedUser) { |
|
| 906 | $event->setUpdatedUser($eventUpdatedUser); |
|
| 907 | $event->stopPropagation(); |
|
| 908 | }, 10); |
|
| 909 | ||
| 910 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 911 | $result = $service->updateUserToken(...$parameters); |
|
| 912 | ||
| 913 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 914 | $notCalledListeners = $this->getListenersStack($traceableEventDispatcher->getNotCalledListeners()); |
|
| 915 | ||
| 916 | $this->assertSame($eventUpdatedUser, $result); |
|
| 917 | $this->assertSame($calledListeners, [ |
|
| 918 | [BeforeUpdateUserTokenEventInterface::class, 10], |
|
| 919 | ]); |
|
| 920 | $this->assertSame($notCalledListeners, [ |
|
| 921 | [BeforeUpdateUserTokenEventInterface::class, 0], |
|
| 922 | [UpdateUserTokenEventInterface::class, 0], |
|
| 923 | ]); |
|
| 924 | } |
|
| 925 | } |
|
| 926 | ||