| @@ 136-164 (lines=29) @@ | ||
| 133 | ]); |
|
| 134 | } |
|
| 135 | ||
| 136 | public function testCopyContentEvents() |
|
| 137 | { |
|
| 138 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 139 | ContentEvents::BEFORE_COPY_CONTENT, |
|
| 140 | ContentEvents::COPY_CONTENT |
|
| 141 | ); |
|
| 142 | ||
| 143 | $parameters = [ |
|
| 144 | $this->createMock(ContentInfo::class), |
|
| 145 | $this->createMock(LocationCreateStruct::class), |
|
| 146 | $this->createMock(VersionInfo::class), |
|
| 147 | ]; |
|
| 148 | ||
| 149 | $content = $this->createMock(Content::class); |
|
| 150 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 151 | $innerServiceMock->method('copyContent')->willReturn($content); |
|
| 152 | ||
| 153 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 154 | $result = $service->copyContent(...$parameters); |
|
| 155 | ||
| 156 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 157 | ||
| 158 | $this->assertSame($content, $result); |
|
| 159 | $this->assertSame($calledListeners, [ |
|
| 160 | [ContentEvents::BEFORE_COPY_CONTENT, 0], |
|
| 161 | [ContentEvents::COPY_CONTENT, 0], |
|
| 162 | ]); |
|
| 163 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 164 | } |
|
| 165 | ||
| 166 | public function testReturnCopyContentResultInBeforeEvents() |
|
| 167 | { |
|
| @@ 241-268 (lines=28) @@ | ||
| 238 | ]); |
|
| 239 | } |
|
| 240 | ||
| 241 | public function testUpdateContentEvents() |
|
| 242 | { |
|
| 243 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 244 | ContentEvents::BEFORE_UPDATE_CONTENT, |
|
| 245 | ContentEvents::UPDATE_CONTENT |
|
| 246 | ); |
|
| 247 | ||
| 248 | $parameters = [ |
|
| 249 | $this->createMock(VersionInfo::class), |
|
| 250 | $this->createMock(ContentUpdateStruct::class), |
|
| 251 | ]; |
|
| 252 | ||
| 253 | $content = $this->createMock(Content::class); |
|
| 254 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 255 | $innerServiceMock->method('updateContent')->willReturn($content); |
|
| 256 | ||
| 257 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 258 | $result = $service->updateContent(...$parameters); |
|
| 259 | ||
| 260 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 261 | ||
| 262 | $this->assertSame($content, $result); |
|
| 263 | $this->assertSame($calledListeners, [ |
|
| 264 | [ContentEvents::BEFORE_UPDATE_CONTENT, 0], |
|
| 265 | [ContentEvents::UPDATE_CONTENT, 0], |
|
| 266 | ]); |
|
| 267 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 268 | } |
|
| 269 | ||
| 270 | public function testReturnUpdateContentResultInBeforeEvents() |
|
| 271 | { |
|
| @@ 618-645 (lines=28) @@ | ||
| 615 | ]); |
|
| 616 | } |
|
| 617 | ||
| 618 | public function testAddRelationEvents() |
|
| 619 | { |
|
| 620 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 621 | ContentEvents::BEFORE_ADD_RELATION, |
|
| 622 | ContentEvents::ADD_RELATION |
|
| 623 | ); |
|
| 624 | ||
| 625 | $parameters = [ |
|
| 626 | $this->createMock(VersionInfo::class), |
|
| 627 | $this->createMock(ContentInfo::class), |
|
| 628 | ]; |
|
| 629 | ||
| 630 | $relation = $this->createMock(Relation::class); |
|
| 631 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 632 | $innerServiceMock->method('addRelation')->willReturn($relation); |
|
| 633 | ||
| 634 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 635 | $result = $service->addRelation(...$parameters); |
|
| 636 | ||
| 637 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 638 | ||
| 639 | $this->assertSame($relation, $result); |
|
| 640 | $this->assertSame($calledListeners, [ |
|
| 641 | [ContentEvents::BEFORE_ADD_RELATION, 0], |
|
| 642 | [ContentEvents::ADD_RELATION, 0], |
|
| 643 | ]); |
|
| 644 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 645 | } |
|
| 646 | ||
| 647 | public function testReturnAddRelationResultInBeforeEvents() |
|
| 648 | { |
|
| @@ 720-747 (lines=28) @@ | ||
| 717 | ]); |
|
| 718 | } |
|
| 719 | ||
| 720 | public function testUpdateContentMetadataEvents() |
|
| 721 | { |
|
| 722 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 723 | ContentEvents::BEFORE_UPDATE_CONTENT_METADATA, |
|
| 724 | ContentEvents::UPDATE_CONTENT_METADATA |
|
| 725 | ); |
|
| 726 | ||
| 727 | $parameters = [ |
|
| 728 | $this->createMock(ContentInfo::class), |
|
| 729 | $this->createMock(ContentMetadataUpdateStruct::class), |
|
| 730 | ]; |
|
| 731 | ||
| 732 | $content = $this->createMock(Content::class); |
|
| 733 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 734 | $innerServiceMock->method('updateContentMetadata')->willReturn($content); |
|
| 735 | ||
| 736 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 737 | $result = $service->updateContentMetadata(...$parameters); |
|
| 738 | ||
| 739 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 740 | ||
| 741 | $this->assertSame($content, $result); |
|
| 742 | $this->assertSame($calledListeners, [ |
|
| 743 | [ContentEvents::BEFORE_UPDATE_CONTENT_METADATA, 0], |
|
| 744 | [ContentEvents::UPDATE_CONTENT_METADATA, 0], |
|
| 745 | ]); |
|
| 746 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 747 | } |
|
| 748 | ||
| 749 | public function testReturnUpdateContentMetadataResultInBeforeEvents() |
|
| 750 | { |
|
| @@ 980-1008 (lines=29) @@ | ||
| 977 | ]); |
|
| 978 | } |
|
| 979 | ||
| 980 | public function testCreateContentDraftEvents() |
|
| 981 | { |
|
| 982 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 983 | ContentEvents::BEFORE_CREATE_CONTENT_DRAFT, |
|
| 984 | ContentEvents::CREATE_CONTENT_DRAFT |
|
| 985 | ); |
|
| 986 | ||
| 987 | $parameters = [ |
|
| 988 | $this->createMock(ContentInfo::class), |
|
| 989 | $this->createMock(VersionInfo::class), |
|
| 990 | $this->createMock(User::class), |
|
| 991 | ]; |
|
| 992 | ||
| 993 | $contentDraft = $this->createMock(Content::class); |
|
| 994 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 995 | $innerServiceMock->method('createContentDraft')->willReturn($contentDraft); |
|
| 996 | ||
| 997 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 998 | $result = $service->createContentDraft(...$parameters); |
|
| 999 | ||
| 1000 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1001 | ||
| 1002 | $this->assertSame($contentDraft, $result); |
|
| 1003 | $this->assertSame($calledListeners, [ |
|
| 1004 | [ContentEvents::BEFORE_CREATE_CONTENT_DRAFT, 0], |
|
| 1005 | [ContentEvents::CREATE_CONTENT_DRAFT, 0], |
|
| 1006 | ]); |
|
| 1007 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1008 | } |
|
| 1009 | ||
| 1010 | public function testReturnCreateContentDraftResultInBeforeEvents() |
|
| 1011 | { |
|
| @@ 1029-1056 (lines=28) @@ | ||
| 1026 | ]); |
|
| 1027 | } |
|
| 1028 | ||
| 1029 | public function testCopyContentTypeEvents() |
|
| 1030 | { |
|
| 1031 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1032 | ContentTypeEvents::BEFORE_COPY_CONTENT_TYPE, |
|
| 1033 | ContentTypeEvents::COPY_CONTENT_TYPE |
|
| 1034 | ); |
|
| 1035 | ||
| 1036 | $parameters = [ |
|
| 1037 | $this->createMock(ContentType::class), |
|
| 1038 | $this->createMock(User::class), |
|
| 1039 | ]; |
|
| 1040 | ||
| 1041 | $contentTypeCopy = $this->createMock(ContentType::class); |
|
| 1042 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 1043 | $innerServiceMock->method('copyContentType')->willReturn($contentTypeCopy); |
|
| 1044 | ||
| 1045 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 1046 | $result = $service->copyContentType(...$parameters); |
|
| 1047 | ||
| 1048 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1049 | ||
| 1050 | $this->assertSame($contentTypeCopy, $result); |
|
| 1051 | $this->assertSame($calledListeners, [ |
|
| 1052 | [ContentTypeEvents::BEFORE_COPY_CONTENT_TYPE, 0], |
|
| 1053 | [ContentTypeEvents::COPY_CONTENT_TYPE, 0], |
|
| 1054 | ]); |
|
| 1055 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1056 | } |
|
| 1057 | ||
| 1058 | public function testReturnCopyContentTypeResultInBeforeEvents() |
|
| 1059 | { |
|
| @@ 27-54 (lines=28) @@ | ||
| 24 | ||
| 25 | class LocationServiceTest extends AbstractServiceTest |
|
| 26 | { |
|
| 27 | public function testCopySubtreeEvents() |
|
| 28 | { |
|
| 29 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 30 | LocationEvents::BEFORE_COPY_SUBTREE, |
|
| 31 | LocationEvents::COPY_SUBTREE |
|
| 32 | ); |
|
| 33 | ||
| 34 | $parameters = [ |
|
| 35 | $this->createMock(Location::class), |
|
| 36 | $this->createMock(Location::class), |
|
| 37 | ]; |
|
| 38 | ||
| 39 | $location = $this->createMock(Location::class); |
|
| 40 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 41 | $innerServiceMock->method('copySubtree')->willReturn($location); |
|
| 42 | ||
| 43 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 44 | $result = $service->copySubtree(...$parameters); |
|
| 45 | ||
| 46 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 47 | ||
| 48 | $this->assertSame($location, $result); |
|
| 49 | $this->assertSame($calledListeners, [ |
|
| 50 | [LocationEvents::BEFORE_COPY_SUBTREE, 0], |
|
| 51 | [LocationEvents::COPY_SUBTREE, 0], |
|
| 52 | ]); |
|
| 53 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 54 | } |
|
| 55 | ||
| 56 | public function testReturnCopySubtreeResultInBeforeEvents() |
|
| 57 | { |
|
| @@ 502-529 (lines=28) @@ | ||
| 499 | ]); |
|
| 500 | } |
|
| 501 | ||
| 502 | public function testUpdateLocationEvents() |
|
| 503 | { |
|
| 504 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 505 | LocationEvents::BEFORE_UPDATE_LOCATION, |
|
| 506 | LocationEvents::UPDATE_LOCATION |
|
| 507 | ); |
|
| 508 | ||
| 509 | $parameters = [ |
|
| 510 | $this->createMock(Location::class), |
|
| 511 | $this->createMock(LocationUpdateStruct::class), |
|
| 512 | ]; |
|
| 513 | ||
| 514 | $updatedLocation = $this->createMock(Location::class); |
|
| 515 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 516 | $innerServiceMock->method('updateLocation')->willReturn($updatedLocation); |
|
| 517 | ||
| 518 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 519 | $result = $service->updateLocation(...$parameters); |
|
| 520 | ||
| 521 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 522 | ||
| 523 | $this->assertSame($updatedLocation, $result); |
|
| 524 | $this->assertSame($calledListeners, [ |
|
| 525 | [LocationEvents::BEFORE_UPDATE_LOCATION, 0], |
|
| 526 | [LocationEvents::UPDATE_LOCATION, 0], |
|
| 527 | ]); |
|
| 528 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 529 | } |
|
| 530 | ||
| 531 | public function testReturnUpdateLocationResultInBeforeEvents() |
|
| 532 | { |
|
| @@ 604-631 (lines=28) @@ | ||
| 601 | ]); |
|
| 602 | } |
|
| 603 | ||
| 604 | public function testCreateLocationEvents() |
|
| 605 | { |
|
| 606 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 607 | LocationEvents::BEFORE_CREATE_LOCATION, |
|
| 608 | LocationEvents::CREATE_LOCATION |
|
| 609 | ); |
|
| 610 | ||
| 611 | $parameters = [ |
|
| 612 | $this->createMock(ContentInfo::class), |
|
| 613 | $this->createMock(LocationCreateStruct::class), |
|
| 614 | ]; |
|
| 615 | ||
| 616 | $location = $this->createMock(Location::class); |
|
| 617 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 618 | $innerServiceMock->method('createLocation')->willReturn($location); |
|
| 619 | ||
| 620 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 621 | $result = $service->createLocation(...$parameters); |
|
| 622 | ||
| 623 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 624 | ||
| 625 | $this->assertSame($location, $result); |
|
| 626 | $this->assertSame($calledListeners, [ |
|
| 627 | [LocationEvents::BEFORE_CREATE_LOCATION, 0], |
|
| 628 | [LocationEvents::CREATE_LOCATION, 0], |
|
| 629 | ]); |
|
| 630 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 631 | } |
|
| 632 | ||
| 633 | public function testReturnCreateLocationResultInBeforeEvents() |
|
| 634 | { |
|
| @@ 190-217 (lines=28) @@ | ||
| 187 | ]); |
|
| 188 | } |
|
| 189 | ||
| 190 | public function testUpdateObjectStateEvents() |
|
| 191 | { |
|
| 192 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 193 | ObjectStateEvents::BEFORE_UPDATE_OBJECT_STATE, |
|
| 194 | ObjectStateEvents::UPDATE_OBJECT_STATE |
|
| 195 | ); |
|
| 196 | ||
| 197 | $parameters = [ |
|
| 198 | $this->createMock(ObjectState::class), |
|
| 199 | $this->createMock(ObjectStateUpdateStruct::class), |
|
| 200 | ]; |
|
| 201 | ||
| 202 | $updatedObjectState = $this->createMock(ObjectState::class); |
|
| 203 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 204 | $innerServiceMock->method('updateObjectState')->willReturn($updatedObjectState); |
|
| 205 | ||
| 206 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 207 | $result = $service->updateObjectState(...$parameters); |
|
| 208 | ||
| 209 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 210 | ||
| 211 | $this->assertSame($updatedObjectState, $result); |
|
| 212 | $this->assertSame($calledListeners, [ |
|
| 213 | [ObjectStateEvents::BEFORE_UPDATE_OBJECT_STATE, 0], |
|
| 214 | [ObjectStateEvents::UPDATE_OBJECT_STATE, 0], |
|
| 215 | ]); |
|
| 216 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 217 | } |
|
| 218 | ||
| 219 | public function testReturnUpdateObjectStateResultInBeforeEvents() |
|
| 220 | { |
|
| @@ 292-319 (lines=28) @@ | ||
| 289 | ]); |
|
| 290 | } |
|
| 291 | ||
| 292 | public function testCreateObjectStateEvents() |
|
| 293 | { |
|
| 294 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 295 | ObjectStateEvents::BEFORE_CREATE_OBJECT_STATE, |
|
| 296 | ObjectStateEvents::CREATE_OBJECT_STATE |
|
| 297 | ); |
|
| 298 | ||
| 299 | $parameters = [ |
|
| 300 | $this->createMock(ObjectStateGroup::class), |
|
| 301 | $this->createMock(ObjectStateCreateStruct::class), |
|
| 302 | ]; |
|
| 303 | ||
| 304 | $objectState = $this->createMock(ObjectState::class); |
|
| 305 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 306 | $innerServiceMock->method('createObjectState')->willReturn($objectState); |
|
| 307 | ||
| 308 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 309 | $result = $service->createObjectState(...$parameters); |
|
| 310 | ||
| 311 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 312 | ||
| 313 | $this->assertSame($objectState, $result); |
|
| 314 | $this->assertSame($calledListeners, [ |
|
| 315 | [ObjectStateEvents::BEFORE_CREATE_OBJECT_STATE, 0], |
|
| 316 | [ObjectStateEvents::CREATE_OBJECT_STATE, 0], |
|
| 317 | ]); |
|
| 318 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 319 | } |
|
| 320 | ||
| 321 | public function testReturnCreateObjectStateResultInBeforeEvents() |
|
| 322 | { |
|
| @@ 394-421 (lines=28) @@ | ||
| 391 | ]); |
|
| 392 | } |
|
| 393 | ||
| 394 | public function testUpdateObjectStateGroupEvents() |
|
| 395 | { |
|
| 396 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 397 | ObjectStateEvents::BEFORE_UPDATE_OBJECT_STATE_GROUP, |
|
| 398 | ObjectStateEvents::UPDATE_OBJECT_STATE_GROUP |
|
| 399 | ); |
|
| 400 | ||
| 401 | $parameters = [ |
|
| 402 | $this->createMock(ObjectStateGroup::class), |
|
| 403 | $this->createMock(ObjectStateGroupUpdateStruct::class), |
|
| 404 | ]; |
|
| 405 | ||
| 406 | $updatedObjectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 407 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 408 | $innerServiceMock->method('updateObjectStateGroup')->willReturn($updatedObjectStateGroup); |
|
| 409 | ||
| 410 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 411 | $result = $service->updateObjectStateGroup(...$parameters); |
|
| 412 | ||
| 413 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 414 | ||
| 415 | $this->assertSame($updatedObjectStateGroup, $result); |
|
| 416 | $this->assertSame($calledListeners, [ |
|
| 417 | [ObjectStateEvents::BEFORE_UPDATE_OBJECT_STATE_GROUP, 0], |
|
| 418 | [ObjectStateEvents::UPDATE_OBJECT_STATE_GROUP, 0], |
|
| 419 | ]); |
|
| 420 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 421 | } |
|
| 422 | ||
| 423 | public function testReturnUpdateObjectStateGroupResultInBeforeEvents() |
|
| 424 | { |
|
| @@ 102-129 (lines=28) @@ | ||
| 99 | ]); |
|
| 100 | } |
|
| 101 | ||
| 102 | public function testUpdateRoleEvents() |
|
| 103 | { |
|
| 104 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 105 | RoleEvents::BEFORE_UPDATE_ROLE, |
|
| 106 | RoleEvents::UPDATE_ROLE |
|
| 107 | ); |
|
| 108 | ||
| 109 | $parameters = [ |
|
| 110 | $this->createMock(Role::class), |
|
| 111 | $this->createMock(RoleUpdateStruct::class), |
|
| 112 | ]; |
|
| 113 | ||
| 114 | $updatedRole = $this->createMock(Role::class); |
|
| 115 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 116 | $innerServiceMock->method('updateRole')->willReturn($updatedRole); |
|
| 117 | ||
| 118 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 119 | $result = $service->updateRole(...$parameters); |
|
| 120 | ||
| 121 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 122 | ||
| 123 | $this->assertSame($updatedRole, $result); |
|
| 124 | $this->assertSame($calledListeners, [ |
|
| 125 | [RoleEvents::BEFORE_UPDATE_ROLE, 0], |
|
| 126 | [RoleEvents::UPDATE_ROLE, 0], |
|
| 127 | ]); |
|
| 128 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 129 | } |
|
| 130 | ||
| 131 | public function testReturnUpdateRoleResultInBeforeEvents() |
|
| 132 | { |
|
| @@ 322-349 (lines=28) @@ | ||
| 319 | ]); |
|
| 320 | } |
|
| 321 | ||
| 322 | public function testAddPolicyEvents() |
|
| 323 | { |
|
| 324 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 325 | RoleEvents::BEFORE_ADD_POLICY, |
|
| 326 | RoleEvents::ADD_POLICY |
|
| 327 | ); |
|
| 328 | ||
| 329 | $parameters = [ |
|
| 330 | $this->createMock(Role::class), |
|
| 331 | $this->createMock(PolicyCreateStruct::class), |
|
| 332 | ]; |
|
| 333 | ||
| 334 | $updatedRole = $this->createMock(Role::class); |
|
| 335 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 336 | $innerServiceMock->method('addPolicy')->willReturn($updatedRole); |
|
| 337 | ||
| 338 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 339 | $result = $service->addPolicy(...$parameters); |
|
| 340 | ||
| 341 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 342 | ||
| 343 | $this->assertSame($updatedRole, $result); |
|
| 344 | $this->assertSame($calledListeners, [ |
|
| 345 | [RoleEvents::BEFORE_ADD_POLICY, 0], |
|
| 346 | [RoleEvents::ADD_POLICY, 0], |
|
| 347 | ]); |
|
| 348 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 349 | } |
|
| 350 | ||
| 351 | public function testReturnAddPolicyResultInBeforeEvents() |
|
| 352 | { |
|
| @@ 424-451 (lines=28) @@ | ||
| 421 | ]); |
|
| 422 | } |
|
| 423 | ||
| 424 | public function testUpdateRoleDraftEvents() |
|
| 425 | { |
|
| 426 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 427 | RoleEvents::BEFORE_UPDATE_ROLE_DRAFT, |
|
| 428 | RoleEvents::UPDATE_ROLE_DRAFT |
|
| 429 | ); |
|
| 430 | ||
| 431 | $parameters = [ |
|
| 432 | $this->createMock(RoleDraft::class), |
|
| 433 | $this->createMock(RoleUpdateStruct::class), |
|
| 434 | ]; |
|
| 435 | ||
| 436 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 437 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 438 | $innerServiceMock->method('updateRoleDraft')->willReturn($updatedRoleDraft); |
|
| 439 | ||
| 440 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 441 | $result = $service->updateRoleDraft(...$parameters); |
|
| 442 | ||
| 443 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 444 | ||
| 445 | $this->assertSame($updatedRoleDraft, $result); |
|
| 446 | $this->assertSame($calledListeners, [ |
|
| 447 | [RoleEvents::BEFORE_UPDATE_ROLE_DRAFT, 0], |
|
| 448 | [RoleEvents::UPDATE_ROLE_DRAFT, 0], |
|
| 449 | ]); |
|
| 450 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 451 | } |
|
| 452 | ||
| 453 | public function testReturnUpdateRoleDraftResultInBeforeEvents() |
|
| 454 | { |
|
| @@ 646-674 (lines=29) @@ | ||
| 643 | ]); |
|
| 644 | } |
|
| 645 | ||
| 646 | public function testUpdatePolicyByRoleDraftEvents() |
|
| 647 | { |
|
| 648 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 649 | RoleEvents::BEFORE_UPDATE_POLICY_BY_ROLE_DRAFT, |
|
| 650 | RoleEvents::UPDATE_POLICY_BY_ROLE_DRAFT |
|
| 651 | ); |
|
| 652 | ||
| 653 | $parameters = [ |
|
| 654 | $this->createMock(RoleDraft::class), |
|
| 655 | $this->createMock(PolicyDraft::class), |
|
| 656 | $this->createMock(PolicyUpdateStruct::class), |
|
| 657 | ]; |
|
| 658 | ||
| 659 | $updatedPolicyDraft = $this->createMock(PolicyDraft::class); |
|
| 660 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 661 | $innerServiceMock->method('updatePolicyByRoleDraft')->willReturn($updatedPolicyDraft); |
|
| 662 | ||
| 663 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 664 | $result = $service->updatePolicyByRoleDraft(...$parameters); |
|
| 665 | ||
| 666 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 667 | ||
| 668 | $this->assertSame($updatedPolicyDraft, $result); |
|
| 669 | $this->assertSame($calledListeners, [ |
|
| 670 | [RoleEvents::BEFORE_UPDATE_POLICY_BY_ROLE_DRAFT, 0], |
|
| 671 | [RoleEvents::UPDATE_POLICY_BY_ROLE_DRAFT, 0], |
|
| 672 | ]); |
|
| 673 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 674 | } |
|
| 675 | ||
| 676 | public function testReturnUpdatePolicyByRoleDraftResultInBeforeEvents() |
|
| 677 | { |
|
| @@ 850-877 (lines=28) @@ | ||
| 847 | ]); |
|
| 848 | } |
|
| 849 | ||
| 850 | public function testRemovePolicyByRoleDraftEvents() |
|
| 851 | { |
|
| 852 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 853 | RoleEvents::BEFORE_REMOVE_POLICY_BY_ROLE_DRAFT, |
|
| 854 | RoleEvents::REMOVE_POLICY_BY_ROLE_DRAFT |
|
| 855 | ); |
|
| 856 | ||
| 857 | $parameters = [ |
|
| 858 | $this->createMock(RoleDraft::class), |
|
| 859 | $this->createMock(PolicyDraft::class), |
|
| 860 | ]; |
|
| 861 | ||
| 862 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 863 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 864 | $innerServiceMock->method('removePolicyByRoleDraft')->willReturn($updatedRoleDraft); |
|
| 865 | ||
| 866 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 867 | $result = $service->removePolicyByRoleDraft(...$parameters); |
|
| 868 | ||
| 869 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 870 | ||
| 871 | $this->assertSame($updatedRoleDraft, $result); |
|
| 872 | $this->assertSame($calledListeners, [ |
|
| 873 | [RoleEvents::BEFORE_REMOVE_POLICY_BY_ROLE_DRAFT, 0], |
|
| 874 | [RoleEvents::REMOVE_POLICY_BY_ROLE_DRAFT, 0], |
|
| 875 | ]); |
|
| 876 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 877 | } |
|
| 878 | ||
| 879 | public function testReturnRemovePolicyByRoleDraftResultInBeforeEvents() |
|
| 880 | { |
|
| @@ 952-979 (lines=28) @@ | ||
| 949 | ]); |
|
| 950 | } |
|
| 951 | ||
| 952 | public function testAddPolicyByRoleDraftEvents() |
|
| 953 | { |
|
| 954 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 955 | RoleEvents::BEFORE_ADD_POLICY_BY_ROLE_DRAFT, |
|
| 956 | RoleEvents::ADD_POLICY_BY_ROLE_DRAFT |
|
| 957 | ); |
|
| 958 | ||
| 959 | $parameters = [ |
|
| 960 | $this->createMock(RoleDraft::class), |
|
| 961 | $this->createMock(PolicyCreateStruct::class), |
|
| 962 | ]; |
|
| 963 | ||
| 964 | $updatedRoleDraft = $this->createMock(RoleDraft::class); |
|
| 965 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 966 | $innerServiceMock->method('addPolicyByRoleDraft')->willReturn($updatedRoleDraft); |
|
| 967 | ||
| 968 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 969 | $result = $service->addPolicyByRoleDraft(...$parameters); |
|
| 970 | ||
| 971 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 972 | ||
| 973 | $this->assertSame($updatedRoleDraft, $result); |
|
| 974 | $this->assertSame($calledListeners, [ |
|
| 975 | [RoleEvents::BEFORE_ADD_POLICY_BY_ROLE_DRAFT, 0], |
|
| 976 | [RoleEvents::ADD_POLICY_BY_ROLE_DRAFT, 0], |
|
| 977 | ]); |
|
| 978 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 979 | } |
|
| 980 | ||
| 981 | public function testReturnAddPolicyByRoleDraftResultInBeforeEvents() |
|
| 982 | { |
|
| @@ 1324-1351 (lines=28) @@ | ||
| 1321 | ]); |
|
| 1322 | } |
|
| 1323 | ||
| 1324 | public function testUpdatePolicyEvents() |
|
| 1325 | { |
|
| 1326 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1327 | RoleEvents::BEFORE_UPDATE_POLICY, |
|
| 1328 | RoleEvents::UPDATE_POLICY |
|
| 1329 | ); |
|
| 1330 | ||
| 1331 | $parameters = [ |
|
| 1332 | $this->createMock(Policy::class), |
|
| 1333 | $this->createMock(PolicyUpdateStruct::class), |
|
| 1334 | ]; |
|
| 1335 | ||
| 1336 | $updatedPolicy = $this->createMock(Policy::class); |
|
| 1337 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 1338 | $innerServiceMock->method('updatePolicy')->willReturn($updatedPolicy); |
|
| 1339 | ||
| 1340 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 1341 | $result = $service->updatePolicy(...$parameters); |
|
| 1342 | ||
| 1343 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1344 | ||
| 1345 | $this->assertSame($updatedPolicy, $result); |
|
| 1346 | $this->assertSame($calledListeners, [ |
|
| 1347 | [RoleEvents::BEFORE_UPDATE_POLICY, 0], |
|
| 1348 | [RoleEvents::UPDATE_POLICY, 0], |
|
| 1349 | ]); |
|
| 1350 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1351 | } |
|
| 1352 | ||
| 1353 | public function testReturnUpdatePolicyResultInBeforeEvents() |
|
| 1354 | { |
|
| @@ 84-111 (lines=28) @@ | ||
| 81 | ]); |
|
| 82 | } |
|
| 83 | ||
| 84 | public function testUpdateSectionEvents() |
|
| 85 | { |
|
| 86 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 87 | SectionEvents::BEFORE_UPDATE_SECTION, |
|
| 88 | SectionEvents::UPDATE_SECTION |
|
| 89 | ); |
|
| 90 | ||
| 91 | $parameters = [ |
|
| 92 | $this->createMock(Section::class), |
|
| 93 | $this->createMock(SectionUpdateStruct::class), |
|
| 94 | ]; |
|
| 95 | ||
| 96 | $updatedSection = $this->createMock(Section::class); |
|
| 97 | $innerServiceMock = $this->createMock(SectionServiceInterface::class); |
|
| 98 | $innerServiceMock->method('updateSection')->willReturn($updatedSection); |
|
| 99 | ||
| 100 | $service = new SectionService($innerServiceMock, $traceableEventDispatcher); |
|
| 101 | $result = $service->updateSection(...$parameters); |
|
| 102 | ||
| 103 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 104 | ||
| 105 | $this->assertSame($updatedSection, $result); |
|
| 106 | $this->assertSame($calledListeners, [ |
|
| 107 | [SectionEvents::BEFORE_UPDATE_SECTION, 0], |
|
| 108 | [SectionEvents::UPDATE_SECTION, 0], |
|
| 109 | ]); |
|
| 110 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 111 | } |
|
| 112 | ||
| 113 | public function testReturnUpdateSectionResultInBeforeEvents() |
|
| 114 | { |
|
| @@ 218-245 (lines=28) @@ | ||
| 215 | ]); |
|
| 216 | } |
|
| 217 | ||
| 218 | public function testRecoverEvents() |
|
| 219 | { |
|
| 220 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 221 | TrashEvents::BEFORE_RECOVER, |
|
| 222 | TrashEvents::RECOVER |
|
| 223 | ); |
|
| 224 | ||
| 225 | $parameters = [ |
|
| 226 | $this->createMock(TrashItem::class), |
|
| 227 | $this->createMock(Location::class), |
|
| 228 | ]; |
|
| 229 | ||
| 230 | $location = $this->createMock(Location::class); |
|
| 231 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 232 | $innerServiceMock->method('recover')->willReturn($location); |
|
| 233 | ||
| 234 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 235 | $result = $service->recover(...$parameters); |
|
| 236 | ||
| 237 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 238 | ||
| 239 | $this->assertSame($location, $result); |
|
| 240 | $this->assertSame($calledListeners, [ |
|
| 241 | [TrashEvents::BEFORE_RECOVER, 0], |
|
| 242 | [TrashEvents::RECOVER, 0], |
|
| 243 | ]); |
|
| 244 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 245 | } |
|
| 246 | ||
| 247 | public function testReturnRecoverResultInBeforeEvents() |
|
| 248 | { |
|
| @@ 18-45 (lines=28) @@ | ||
| 15 | ||
| 16 | class URLServiceTest extends AbstractServiceTest |
|
| 17 | { |
|
| 18 | public function testUpdateUrlEvents() |
|
| 19 | { |
|
| 20 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 21 | URLEvents::BEFORE_UPDATE_URL, |
|
| 22 | URLEvents::UPDATE_URL |
|
| 23 | ); |
|
| 24 | ||
| 25 | $parameters = [ |
|
| 26 | $this->createMock(URL::class), |
|
| 27 | $this->createMock(URLUpdateStruct::class), |
|
| 28 | ]; |
|
| 29 | ||
| 30 | $updatedUrl = $this->createMock(URL::class); |
|
| 31 | $innerServiceMock = $this->createMock(URLServiceInterface::class); |
|
| 32 | $innerServiceMock->method('updateUrl')->willReturn($updatedUrl); |
|
| 33 | ||
| 34 | $service = new URLService($innerServiceMock, $traceableEventDispatcher); |
|
| 35 | $result = $service->updateUrl(...$parameters); |
|
| 36 | ||
| 37 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 38 | ||
| 39 | $this->assertSame($updatedUrl, $result); |
|
| 40 | $this->assertSame($calledListeners, [ |
|
| 41 | [URLEvents::BEFORE_UPDATE_URL, 0], |
|
| 42 | [URLEvents::UPDATE_URL, 0], |
|
| 43 | ]); |
|
| 44 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 45 | } |
|
| 46 | ||
| 47 | public function testReturnUpdateUrlResultInBeforeEvents() |
|
| 48 | { |
|
| @@ 32-59 (lines=28) @@ | ||
| 29 | ||
| 30 | class UserServiceTest extends AbstractServiceTest |
|
| 31 | { |
|
| 32 | public function testUpdateUserGroupEvents() |
|
| 33 | { |
|
| 34 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 35 | UserEvents::BEFORE_UPDATE_USER_GROUP, |
|
| 36 | UserEvents::UPDATE_USER_GROUP |
|
| 37 | ); |
|
| 38 | ||
| 39 | $parameters = [ |
|
| 40 | $this->createMock(UserGroup::class), |
|
| 41 | $this->createMock(UserGroupUpdateStruct::class), |
|
| 42 | ]; |
|
| 43 | ||
| 44 | $updatedUserGroup = $this->createMock(UserGroup::class); |
|
| 45 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 46 | $innerServiceMock->method('updateUserGroup')->willReturn($updatedUserGroup); |
|
| 47 | ||
| 48 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 49 | $result = $service->updateUserGroup(...$parameters); |
|
| 50 | ||
| 51 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 52 | ||
| 53 | $this->assertSame($updatedUserGroup, $result); |
|
| 54 | $this->assertSame($calledListeners, [ |
|
| 55 | [UserEvents::BEFORE_UPDATE_USER_GROUP, 0], |
|
| 56 | [UserEvents::UPDATE_USER_GROUP, 0], |
|
| 57 | ]); |
|
| 58 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 59 | } |
|
| 60 | ||
| 61 | public function testReturnUpdateUserGroupResultInBeforeEvents() |
|
| 62 | { |
|
| @@ 134-161 (lines=28) @@ | ||
| 131 | ]); |
|
| 132 | } |
|
| 133 | ||
| 134 | public function testUpdateUserEvents() |
|
| 135 | { |
|
| 136 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 137 | UserEvents::BEFORE_UPDATE_USER, |
|
| 138 | UserEvents::UPDATE_USER |
|
| 139 | ); |
|
| 140 | ||
| 141 | $parameters = [ |
|
| 142 | $this->createMock(User::class), |
|
| 143 | $this->createMock(UserUpdateStruct::class), |
|
| 144 | ]; |
|
| 145 | ||
| 146 | $updatedUser = $this->createMock(User::class); |
|
| 147 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 148 | $innerServiceMock->method('updateUser')->willReturn($updatedUser); |
|
| 149 | ||
| 150 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 151 | $result = $service->updateUser(...$parameters); |
|
| 152 | ||
| 153 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 154 | ||
| 155 | $this->assertSame($updatedUser, $result); |
|
| 156 | $this->assertSame($calledListeners, [ |
|
| 157 | [UserEvents::BEFORE_UPDATE_USER, 0], |
|
| 158 | [UserEvents::UPDATE_USER, 0], |
|
| 159 | ]); |
|
| 160 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 161 | } |
|
| 162 | ||
| 163 | public function testReturnUpdateUserResultInBeforeEvents() |
|
| 164 | { |
|
| @@ 713-740 (lines=28) @@ | ||
| 710 | ]); |
|
| 711 | } |
|
| 712 | ||
| 713 | public function testCreateUserGroupEvents() |
|
| 714 | { |
|
| 715 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 716 | UserEvents::BEFORE_CREATE_USER_GROUP, |
|
| 717 | UserEvents::CREATE_USER_GROUP |
|
| 718 | ); |
|
| 719 | ||
| 720 | $parameters = [ |
|
| 721 | $this->createMock(UserGroupCreateStruct::class), |
|
| 722 | $this->createMock(UserGroup::class), |
|
| 723 | ]; |
|
| 724 | ||
| 725 | $userGroup = $this->createMock(UserGroup::class); |
|
| 726 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 727 | $innerServiceMock->method('createUserGroup')->willReturn($userGroup); |
|
| 728 | ||
| 729 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 730 | $result = $service->createUserGroup(...$parameters); |
|
| 731 | ||
| 732 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 733 | ||
| 734 | $this->assertSame($userGroup, $result); |
|
| 735 | $this->assertSame($calledListeners, [ |
|
| 736 | [UserEvents::BEFORE_CREATE_USER_GROUP, 0], |
|
| 737 | [UserEvents::CREATE_USER_GROUP, 0], |
|
| 738 | ]); |
|
| 739 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 740 | } |
|
| 741 | ||
| 742 | public function testReturnCreateUserGroupResultInBeforeEvents() |
|
| 743 | { |
|
| @@ 815-842 (lines=28) @@ | ||
| 812 | ]); |
|
| 813 | } |
|
| 814 | ||
| 815 | public function testUpdateUserTokenEvents() |
|
| 816 | { |
|
| 817 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 818 | UserEvents::BEFORE_UPDATE_USER_TOKEN, |
|
| 819 | UserEvents::UPDATE_USER_TOKEN |
|
| 820 | ); |
|
| 821 | ||
| 822 | $parameters = [ |
|
| 823 | $this->createMock(User::class), |
|
| 824 | $this->createMock(UserTokenUpdateStruct::class), |
|
| 825 | ]; |
|
| 826 | ||
| 827 | $updatedUser = $this->createMock(User::class); |
|
| 828 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 829 | $innerServiceMock->method('updateUserToken')->willReturn($updatedUser); |
|
| 830 | ||
| 831 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 832 | $result = $service->updateUserToken(...$parameters); |
|
| 833 | ||
| 834 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 835 | ||
| 836 | $this->assertSame($updatedUser, $result); |
|
| 837 | $this->assertSame($calledListeners, [ |
|
| 838 | [UserEvents::BEFORE_UPDATE_USER_TOKEN, 0], |
|
| 839 | [UserEvents::UPDATE_USER_TOKEN, 0], |
|
| 840 | ]); |
|
| 841 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 842 | } |
|
| 843 | ||
| 844 | public function testReturnUpdateUserTokenResultInBeforeEvents() |
|
| 845 | { |
|