| @@ 49-75 (lines=27) @@ | ||
| 46 | ||
| 47 | class ContentServiceTest extends AbstractServiceTest |
|
| 48 | { |
|
| 49 | public function testDeleteContentEvents() |
|
| 50 | { |
|
| 51 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 52 | BeforeDeleteContentEvent::class, |
|
| 53 | DeleteContentEvent::class |
|
| 54 | ); |
|
| 55 | ||
| 56 | $parameters = [ |
|
| 57 | $this->createMock(ContentInfo::class), |
|
| 58 | ]; |
|
| 59 | ||
| 60 | $locations = []; |
|
| 61 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 62 | $innerServiceMock->method('deleteContent')->willReturn($locations); |
|
| 63 | ||
| 64 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 65 | $result = $service->deleteContent(...$parameters); |
|
| 66 | ||
| 67 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 68 | ||
| 69 | $this->assertSame($locations, $result); |
|
| 70 | $this->assertSame($calledListeners, [ |
|
| 71 | [BeforeDeleteContentEvent::class, 0], |
|
| 72 | [DeleteContentEvent::class, 0], |
|
| 73 | ]); |
|
| 74 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 75 | } |
|
| 76 | ||
| 77 | public function testReturnDeleteContentResultInBeforeEvents() |
|
| 78 | { |
|
| @@ 414-441 (lines=28) @@ | ||
| 411 | ]); |
|
| 412 | } |
|
| 413 | ||
| 414 | public function testCreateContentEvents() |
|
| 415 | { |
|
| 416 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 417 | BeforeCreateContentEvent::class, |
|
| 418 | CreateContentEvent::class |
|
| 419 | ); |
|
| 420 | ||
| 421 | $parameters = [ |
|
| 422 | $this->createMock(ContentCreateStruct::class), |
|
| 423 | [], |
|
| 424 | ]; |
|
| 425 | ||
| 426 | $content = $this->createMock(Content::class); |
|
| 427 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 428 | $innerServiceMock->method('createContent')->willReturn($content); |
|
| 429 | ||
| 430 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 431 | $result = $service->createContent(...$parameters); |
|
| 432 | ||
| 433 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 434 | ||
| 435 | $this->assertSame($content, $result); |
|
| 436 | $this->assertSame($calledListeners, [ |
|
| 437 | [BeforeCreateContentEvent::class, 0], |
|
| 438 | [CreateContentEvent::class, 0], |
|
| 439 | ]); |
|
| 440 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 441 | } |
|
| 442 | ||
| 443 | public function testReturnCreateContentResultInBeforeEvents() |
|
| 444 | { |
|
| @@ 893-920 (lines=28) @@ | ||
| 890 | ]); |
|
| 891 | } |
|
| 892 | ||
| 893 | public function testPublishVersionEvents() |
|
| 894 | { |
|
| 895 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 896 | BeforePublishVersionEvent::class, |
|
| 897 | PublishVersionEvent::class |
|
| 898 | ); |
|
| 899 | ||
| 900 | $parameters = [ |
|
| 901 | $this->createMock(VersionInfo::class), |
|
| 902 | [], |
|
| 903 | ]; |
|
| 904 | ||
| 905 | $content = $this->createMock(Content::class); |
|
| 906 | $innerServiceMock = $this->createMock(ContentServiceInterface::class); |
|
| 907 | $innerServiceMock->method('publishVersion')->willReturn($content); |
|
| 908 | ||
| 909 | $service = new ContentService($innerServiceMock, $traceableEventDispatcher); |
|
| 910 | $result = $service->publishVersion(...$parameters); |
|
| 911 | ||
| 912 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 913 | ||
| 914 | $this->assertSame($content, $result); |
|
| 915 | $this->assertSame($calledListeners, [ |
|
| 916 | [BeforePublishVersionEvent::class, 0], |
|
| 917 | [PublishVersionEvent::class, 0], |
|
| 918 | ]); |
|
| 919 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 920 | } |
|
| 921 | ||
| 922 | public function testReturnPublishVersionResultInBeforeEvents() |
|
| 923 | { |
|
| @@ 171-197 (lines=27) @@ | ||
| 168 | ]); |
|
| 169 | } |
|
| 170 | ||
| 171 | public function testCreateContentTypeDraftEvents() |
|
| 172 | { |
|
| 173 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 174 | BeforeCreateContentTypeDraftEvent::class, |
|
| 175 | CreateContentTypeDraftEvent::class |
|
| 176 | ); |
|
| 177 | ||
| 178 | $parameters = [ |
|
| 179 | $this->createMock(ContentType::class), |
|
| 180 | ]; |
|
| 181 | ||
| 182 | $contentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 183 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 184 | $innerServiceMock->method('createContentTypeDraft')->willReturn($contentTypeDraft); |
|
| 185 | ||
| 186 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 187 | $result = $service->createContentTypeDraft(...$parameters); |
|
| 188 | ||
| 189 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 190 | ||
| 191 | $this->assertSame($contentTypeDraft, $result); |
|
| 192 | $this->assertSame($calledListeners, [ |
|
| 193 | [BeforeCreateContentTypeDraftEvent::class, 0], |
|
| 194 | [CreateContentTypeDraftEvent::class, 0], |
|
| 195 | ]); |
|
| 196 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 197 | } |
|
| 198 | ||
| 199 | public function testReturnCreateContentTypeDraftResultInBeforeEvents() |
|
| 200 | { |
|
| @@ 270-296 (lines=27) @@ | ||
| 267 | ]); |
|
| 268 | } |
|
| 269 | ||
| 270 | public function testCreateContentTypeGroupEvents() |
|
| 271 | { |
|
| 272 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 273 | BeforeCreateContentTypeGroupEvent::class, |
|
| 274 | CreateContentTypeGroupEvent::class |
|
| 275 | ); |
|
| 276 | ||
| 277 | $parameters = [ |
|
| 278 | $this->createMock(ContentTypeGroupCreateStruct::class), |
|
| 279 | ]; |
|
| 280 | ||
| 281 | $contentTypeGroup = $this->createMock(ContentTypeGroup::class); |
|
| 282 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 283 | $innerServiceMock->method('createContentTypeGroup')->willReturn($contentTypeGroup); |
|
| 284 | ||
| 285 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 286 | $result = $service->createContentTypeGroup(...$parameters); |
|
| 287 | ||
| 288 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 289 | ||
| 290 | $this->assertSame($contentTypeGroup, $result); |
|
| 291 | $this->assertSame($calledListeners, [ |
|
| 292 | [BeforeCreateContentTypeGroupEvent::class, 0], |
|
| 293 | [CreateContentTypeGroupEvent::class, 0], |
|
| 294 | ]); |
|
| 295 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 296 | } |
|
| 297 | ||
| 298 | public function testReturnCreateContentTypeGroupResultInBeforeEvents() |
|
| 299 | { |
|
| @@ 428-455 (lines=28) @@ | ||
| 425 | ]); |
|
| 426 | } |
|
| 427 | ||
| 428 | public function testCreateContentTypeEvents() |
|
| 429 | { |
|
| 430 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 431 | BeforeCreateContentTypeEvent::class, |
|
| 432 | CreateContentTypeEvent::class |
|
| 433 | ); |
|
| 434 | ||
| 435 | $parameters = [ |
|
| 436 | $this->createMock(ContentTypeCreateStruct::class), |
|
| 437 | [], |
|
| 438 | ]; |
|
| 439 | ||
| 440 | $contentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 441 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 442 | $innerServiceMock->method('createContentType')->willReturn($contentTypeDraft); |
|
| 443 | ||
| 444 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 445 | $result = $service->createContentType(...$parameters); |
|
| 446 | ||
| 447 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 448 | ||
| 449 | $this->assertSame($contentTypeDraft, $result); |
|
| 450 | $this->assertSame($calledListeners, [ |
|
| 451 | [BeforeCreateContentTypeEvent::class, 0], |
|
| 452 | [CreateContentTypeEvent::class, 0], |
|
| 453 | ]); |
|
| 454 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 455 | } |
|
| 456 | ||
| 457 | public function testReturnCreateContentTypeResultInBeforeEvents() |
|
| 458 | { |
|
| @@ 530-557 (lines=28) @@ | ||
| 527 | ]); |
|
| 528 | } |
|
| 529 | ||
| 530 | public function testRemoveContentTypeTranslationEvents() |
|
| 531 | { |
|
| 532 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 533 | BeforeRemoveContentTypeTranslationEvent::class, |
|
| 534 | RemoveContentTypeTranslationEvent::class |
|
| 535 | ); |
|
| 536 | ||
| 537 | $parameters = [ |
|
| 538 | $this->createMock(ContentTypeDraft::class), |
|
| 539 | 'random_value_5cff79c318f864.57583321', |
|
| 540 | ]; |
|
| 541 | ||
| 542 | $newContentTypeDraft = $this->createMock(ContentTypeDraft::class); |
|
| 543 | $innerServiceMock = $this->createMock(ContentTypeServiceInterface::class); |
|
| 544 | $innerServiceMock->method('removeContentTypeTranslation')->willReturn($newContentTypeDraft); |
|
| 545 | ||
| 546 | $service = new ContentTypeService($innerServiceMock, $traceableEventDispatcher); |
|
| 547 | $result = $service->removeContentTypeTranslation(...$parameters); |
|
| 548 | ||
| 549 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 550 | ||
| 551 | $this->assertSame($newContentTypeDraft, $result); |
|
| 552 | $this->assertSame($calledListeners, [ |
|
| 553 | [BeforeRemoveContentTypeTranslationEvent::class, 0], |
|
| 554 | [RemoveContentTypeTranslationEvent::class, 0], |
|
| 555 | ]); |
|
| 556 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 557 | } |
|
| 558 | ||
| 559 | public function testReturnRemoveContentTypeTranslationResultInBeforeEvents() |
|
| 560 | { |
|
| @@ 83-109 (lines=27) @@ | ||
| 80 | ]); |
|
| 81 | } |
|
| 82 | ||
| 83 | public function testCreateLanguageEvents() |
|
| 84 | { |
|
| 85 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 86 | BeforeCreateLanguageEvent::class, |
|
| 87 | CreateLanguageEvent::class |
|
| 88 | ); |
|
| 89 | ||
| 90 | $parameters = [ |
|
| 91 | $this->createMock(LanguageCreateStruct::class), |
|
| 92 | ]; |
|
| 93 | ||
| 94 | $language = $this->createMock(Language::class); |
|
| 95 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 96 | $innerServiceMock->method('createLanguage')->willReturn($language); |
|
| 97 | ||
| 98 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 99 | $result = $service->createLanguage(...$parameters); |
|
| 100 | ||
| 101 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 102 | ||
| 103 | $this->assertSame($language, $result); |
|
| 104 | $this->assertSame($calledListeners, [ |
|
| 105 | [BeforeCreateLanguageEvent::class, 0], |
|
| 106 | [CreateLanguageEvent::class, 0], |
|
| 107 | ]); |
|
| 108 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 109 | } |
|
| 110 | ||
| 111 | public function testReturnCreateLanguageResultInBeforeEvents() |
|
| 112 | { |
|
| @@ 182-209 (lines=28) @@ | ||
| 179 | ]); |
|
| 180 | } |
|
| 181 | ||
| 182 | public function testUpdateLanguageNameEvents() |
|
| 183 | { |
|
| 184 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 185 | BeforeUpdateLanguageNameEvent::class, |
|
| 186 | UpdateLanguageNameEvent::class |
|
| 187 | ); |
|
| 188 | ||
| 189 | $parameters = [ |
|
| 190 | $this->createMock(Language::class), |
|
| 191 | 'random_value_5cff79c3161276.87987683', |
|
| 192 | ]; |
|
| 193 | ||
| 194 | $updatedLanguage = $this->createMock(Language::class); |
|
| 195 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 196 | $innerServiceMock->method('updateLanguageName')->willReturn($updatedLanguage); |
|
| 197 | ||
| 198 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 199 | $result = $service->updateLanguageName(...$parameters); |
|
| 200 | ||
| 201 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 202 | ||
| 203 | $this->assertSame($updatedLanguage, $result); |
|
| 204 | $this->assertSame($calledListeners, [ |
|
| 205 | [BeforeUpdateLanguageNameEvent::class, 0], |
|
| 206 | [UpdateLanguageNameEvent::class, 0], |
|
| 207 | ]); |
|
| 208 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 209 | } |
|
| 210 | ||
| 211 | public function testReturnUpdateLanguageNameResultInBeforeEvents() |
|
| 212 | { |
|
| @@ 284-310 (lines=27) @@ | ||
| 281 | ]); |
|
| 282 | } |
|
| 283 | ||
| 284 | public function testDisableLanguageEvents() |
|
| 285 | { |
|
| 286 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 287 | BeforeDisableLanguageEvent::class, |
|
| 288 | DisableLanguageEvent::class |
|
| 289 | ); |
|
| 290 | ||
| 291 | $parameters = [ |
|
| 292 | $this->createMock(Language::class), |
|
| 293 | ]; |
|
| 294 | ||
| 295 | $disabledLanguage = $this->createMock(Language::class); |
|
| 296 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 297 | $innerServiceMock->method('disableLanguage')->willReturn($disabledLanguage); |
|
| 298 | ||
| 299 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 300 | $result = $service->disableLanguage(...$parameters); |
|
| 301 | ||
| 302 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 303 | ||
| 304 | $this->assertSame($disabledLanguage, $result); |
|
| 305 | $this->assertSame($calledListeners, [ |
|
| 306 | [BeforeDisableLanguageEvent::class, 0], |
|
| 307 | [DisableLanguageEvent::class, 0], |
|
| 308 | ]); |
|
| 309 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 310 | } |
|
| 311 | ||
| 312 | public function testReturnDisableLanguageResultInBeforeEvents() |
|
| 313 | { |
|
| @@ 383-409 (lines=27) @@ | ||
| 380 | ]); |
|
| 381 | } |
|
| 382 | ||
| 383 | public function testEnableLanguageEvents() |
|
| 384 | { |
|
| 385 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 386 | BeforeEnableLanguageEvent::class, |
|
| 387 | EnableLanguageEvent::class |
|
| 388 | ); |
|
| 389 | ||
| 390 | $parameters = [ |
|
| 391 | $this->createMock(Language::class), |
|
| 392 | ]; |
|
| 393 | ||
| 394 | $enabledLanguage = $this->createMock(Language::class); |
|
| 395 | $innerServiceMock = $this->createMock(LanguageServiceInterface::class); |
|
| 396 | $innerServiceMock->method('enableLanguage')->willReturn($enabledLanguage); |
|
| 397 | ||
| 398 | $service = new LanguageService($innerServiceMock, $traceableEventDispatcher); |
|
| 399 | $result = $service->enableLanguage(...$parameters); |
|
| 400 | ||
| 401 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 402 | ||
| 403 | $this->assertSame($enabledLanguage, $result); |
|
| 404 | $this->assertSame($calledListeners, [ |
|
| 405 | [BeforeEnableLanguageEvent::class, 0], |
|
| 406 | [EnableLanguageEvent::class, 0], |
|
| 407 | ]); |
|
| 408 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 409 | } |
|
| 410 | ||
| 411 | public function testReturnEnableLanguageResultInBeforeEvents() |
|
| 412 | { |
|
| @@ 193-219 (lines=27) @@ | ||
| 190 | ]); |
|
| 191 | } |
|
| 192 | ||
| 193 | public function testUnhideLocationEvents() |
|
| 194 | { |
|
| 195 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 196 | BeforeUnhideLocationEvent::class, |
|
| 197 | UnhideLocationEvent::class |
|
| 198 | ); |
|
| 199 | ||
| 200 | $parameters = [ |
|
| 201 | $this->createMock(Location::class), |
|
| 202 | ]; |
|
| 203 | ||
| 204 | $revealedLocation = $this->createMock(Location::class); |
|
| 205 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 206 | $innerServiceMock->method('unhideLocation')->willReturn($revealedLocation); |
|
| 207 | ||
| 208 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 209 | $result = $service->unhideLocation(...$parameters); |
|
| 210 | ||
| 211 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 212 | ||
| 213 | $this->assertSame($revealedLocation, $result); |
|
| 214 | $this->assertSame($calledListeners, [ |
|
| 215 | [BeforeUnhideLocationEvent::class, 0], |
|
| 216 | [UnhideLocationEvent::class, 0], |
|
| 217 | ]); |
|
| 218 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 219 | } |
|
| 220 | ||
| 221 | public function testReturnUnhideLocationResultInBeforeEvents() |
|
| 222 | { |
|
| @@ 292-318 (lines=27) @@ | ||
| 289 | ]); |
|
| 290 | } |
|
| 291 | ||
| 292 | public function testHideLocationEvents() |
|
| 293 | { |
|
| 294 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 295 | BeforeHideLocationEvent::class, |
|
| 296 | HideLocationEvent::class |
|
| 297 | ); |
|
| 298 | ||
| 299 | $parameters = [ |
|
| 300 | $this->createMock(Location::class), |
|
| 301 | ]; |
|
| 302 | ||
| 303 | $hiddenLocation = $this->createMock(Location::class); |
|
| 304 | $innerServiceMock = $this->createMock(LocationServiceInterface::class); |
|
| 305 | $innerServiceMock->method('hideLocation')->willReturn($hiddenLocation); |
|
| 306 | ||
| 307 | $service = new LocationService($innerServiceMock, $traceableEventDispatcher); |
|
| 308 | $result = $service->hideLocation(...$parameters); |
|
| 309 | ||
| 310 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 311 | ||
| 312 | $this->assertSame($hiddenLocation, $result); |
|
| 313 | $this->assertSame($calledListeners, [ |
|
| 314 | [BeforeHideLocationEvent::class, 0], |
|
| 315 | [HideLocationEvent::class, 0], |
|
| 316 | ]); |
|
| 317 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 318 | } |
|
| 319 | ||
| 320 | public function testReturnHideLocationResultInBeforeEvents() |
|
| 321 | { |
|
| @@ 22-48 (lines=27) @@ | ||
| 19 | ||
| 20 | class NotificationServiceTest extends AbstractServiceTest |
|
| 21 | { |
|
| 22 | public function testCreateNotificationEvents() |
|
| 23 | { |
|
| 24 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 25 | BeforeCreateNotificationEvent::class, |
|
| 26 | CreateNotificationEvent::class |
|
| 27 | ); |
|
| 28 | ||
| 29 | $parameters = [ |
|
| 30 | $this->createMock(CreateStruct::class), |
|
| 31 | ]; |
|
| 32 | ||
| 33 | $notification = $this->createMock(Notification::class); |
|
| 34 | $innerServiceMock = $this->createMock(NotificationServiceInterface::class); |
|
| 35 | $innerServiceMock->method('createNotification')->willReturn($notification); |
|
| 36 | ||
| 37 | $service = new NotificationService($innerServiceMock, $traceableEventDispatcher); |
|
| 38 | $result = $service->createNotification(...$parameters); |
|
| 39 | ||
| 40 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 41 | ||
| 42 | $this->assertSame($notification, $result); |
|
| 43 | $this->assertSame($calledListeners, [ |
|
| 44 | [BeforeCreateNotificationEvent::class, 0], |
|
| 45 | [CreateNotificationEvent::class, 0], |
|
| 46 | ]); |
|
| 47 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 48 | } |
|
| 49 | ||
| 50 | public function testReturnCreateNotificationResultInBeforeEvents() |
|
| 51 | { |
|
| @@ 98-124 (lines=27) @@ | ||
| 95 | ]); |
|
| 96 | } |
|
| 97 | ||
| 98 | public function testCreateObjectStateGroupEvents() |
|
| 99 | { |
|
| 100 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 101 | BeforeCreateObjectStateGroupEvent::class, |
|
| 102 | CreateObjectStateGroupEvent::class |
|
| 103 | ); |
|
| 104 | ||
| 105 | $parameters = [ |
|
| 106 | $this->createMock(ObjectStateGroupCreateStruct::class), |
|
| 107 | ]; |
|
| 108 | ||
| 109 | $objectStateGroup = $this->createMock(ObjectStateGroup::class); |
|
| 110 | $innerServiceMock = $this->createMock(ObjectStateServiceInterface::class); |
|
| 111 | $innerServiceMock->method('createObjectStateGroup')->willReturn($objectStateGroup); |
|
| 112 | ||
| 113 | $service = new ObjectStateService($innerServiceMock, $traceableEventDispatcher); |
|
| 114 | $result = $service->createObjectStateGroup(...$parameters); |
|
| 115 | ||
| 116 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 117 | ||
| 118 | $this->assertSame($objectStateGroup, $result); |
|
| 119 | $this->assertSame($calledListeners, [ |
|
| 120 | [BeforeCreateObjectStateGroupEvent::class, 0], |
|
| 121 | [CreateObjectStateGroupEvent::class, 0], |
|
| 122 | ]); |
|
| 123 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function testReturnCreateObjectStateGroupResultInBeforeEvents() |
|
| 127 | { |
|
| @@ 306-332 (lines=27) @@ | ||
| 303 | ]); |
|
| 304 | } |
|
| 305 | ||
| 306 | public function testCreateSectionEvents() |
|
| 307 | { |
|
| 308 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 309 | BeforeCreateSectionEvent::class, |
|
| 310 | CreateSectionEvent::class |
|
| 311 | ); |
|
| 312 | ||
| 313 | $parameters = [ |
|
| 314 | $this->createMock(SectionCreateStruct::class), |
|
| 315 | ]; |
|
| 316 | ||
| 317 | $section = $this->createMock(Section::class); |
|
| 318 | $innerServiceMock = $this->createMock(SectionServiceInterface::class); |
|
| 319 | $innerServiceMock->method('createSection')->willReturn($section); |
|
| 320 | ||
| 321 | $service = new SectionService($innerServiceMock, $traceableEventDispatcher); |
|
| 322 | $result = $service->createSection(...$parameters); |
|
| 323 | ||
| 324 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 325 | ||
| 326 | $this->assertSame($section, $result); |
|
| 327 | $this->assertSame($calledListeners, [ |
|
| 328 | [BeforeCreateSectionEvent::class, 0], |
|
| 329 | [CreateSectionEvent::class, 0], |
|
| 330 | ]); |
|
| 331 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 332 | } |
|
| 333 | ||
| 334 | public function testReturnCreateSectionResultInBeforeEvents() |
|
| 335 | { |
|
| @@ 26-51 (lines=26) @@ | ||
| 23 | ||
| 24 | class TrashServiceTest extends AbstractServiceTest |
|
| 25 | { |
|
| 26 | public function testEmptyTrashEvents() |
|
| 27 | { |
|
| 28 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 29 | BeforeEmptyTrashEvent::class, |
|
| 30 | EmptyTrashEvent::class |
|
| 31 | ); |
|
| 32 | ||
| 33 | $parameters = [ |
|
| 34 | ]; |
|
| 35 | ||
| 36 | $resultList = $this->createMock(TrashItemDeleteResultList::class); |
|
| 37 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 38 | $innerServiceMock->method('emptyTrash')->willReturn($resultList); |
|
| 39 | ||
| 40 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 41 | $result = $service->emptyTrash(...$parameters); |
|
| 42 | ||
| 43 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 44 | ||
| 45 | $this->assertSame($resultList, $result); |
|
| 46 | $this->assertSame($calledListeners, [ |
|
| 47 | [BeforeEmptyTrashEvent::class, 0], |
|
| 48 | [EmptyTrashEvent::class, 0], |
|
| 49 | ]); |
|
| 50 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 51 | } |
|
| 52 | ||
| 53 | public function testReturnEmptyTrashResultInBeforeEvents() |
|
| 54 | { |
|
| @@ 122-148 (lines=27) @@ | ||
| 119 | ]); |
|
| 120 | } |
|
| 121 | ||
| 122 | public function testTrashEvents() |
|
| 123 | { |
|
| 124 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 125 | BeforeTrashEvent::class, |
|
| 126 | TrashEvent::class |
|
| 127 | ); |
|
| 128 | ||
| 129 | $parameters = [ |
|
| 130 | $this->createMock(Location::class), |
|
| 131 | ]; |
|
| 132 | ||
| 133 | $trashItem = $this->createMock(TrashItem::class); |
|
| 134 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 135 | $innerServiceMock->method('trash')->willReturn($trashItem); |
|
| 136 | ||
| 137 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 138 | $result = $service->trash(...$parameters); |
|
| 139 | ||
| 140 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 141 | ||
| 142 | $this->assertSame($trashItem, $result); |
|
| 143 | $this->assertSame($calledListeners, [ |
|
| 144 | [BeforeTrashEvent::class, 0], |
|
| 145 | [TrashEvent::class, 0], |
|
| 146 | ]); |
|
| 147 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 148 | } |
|
| 149 | ||
| 150 | public function testReturnTrashResultInBeforeEvents() |
|
| 151 | { |
|
| @@ 323-349 (lines=27) @@ | ||
| 320 | ]); |
|
| 321 | } |
|
| 322 | ||
| 323 | public function testDeleteTrashItemEvents() |
|
| 324 | { |
|
| 325 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 326 | BeforeDeleteTrashItemEvent::class, |
|
| 327 | DeleteTrashItemEvent::class |
|
| 328 | ); |
|
| 329 | ||
| 330 | $parameters = [ |
|
| 331 | $this->createMock(TrashItem::class), |
|
| 332 | ]; |
|
| 333 | ||
| 334 | $result = $this->createMock(TrashItemDeleteResult::class); |
|
| 335 | $innerServiceMock = $this->createMock(TrashServiceInterface::class); |
|
| 336 | $innerServiceMock->method('deleteTrashItem')->willReturn($result); |
|
| 337 | ||
| 338 | $service = new TrashService($innerServiceMock, $traceableEventDispatcher); |
|
| 339 | $result = $service->deleteTrashItem(...$parameters); |
|
| 340 | ||
| 341 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 342 | ||
| 343 | $this->assertSame($result, $result); |
|
| 344 | $this->assertSame($calledListeners, [ |
|
| 345 | [BeforeDeleteTrashItemEvent::class, 0], |
|
| 346 | [DeleteTrashItemEvent::class, 0], |
|
| 347 | ]); |
|
| 348 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 349 | } |
|
| 350 | ||
| 351 | public function testReturnDeleteTrashItemResultInBeforeEvents() |
|
| 352 | { |
|
| @@ 184-210 (lines=27) @@ | ||
| 181 | ]); |
|
| 182 | } |
|
| 183 | ||
| 184 | public function testTranslateEvents() |
|
| 185 | { |
|
| 186 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 187 | BeforeTranslateEvent::class, |
|
| 188 | TranslateEvent::class |
|
| 189 | ); |
|
| 190 | ||
| 191 | $parameters = [ |
|
| 192 | 'random_value_5cff79c316cfa7.72466150', |
|
| 193 | ]; |
|
| 194 | ||
| 195 | $result = $this->createMock(URLWildcardTranslationResult::class); |
|
| 196 | $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class); |
|
| 197 | $innerServiceMock->method('translate')->willReturn($result); |
|
| 198 | ||
| 199 | $service = new URLWildcardService($innerServiceMock, $traceableEventDispatcher); |
|
| 200 | $result = $service->translate(...$parameters); |
|
| 201 | ||
| 202 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 203 | ||
| 204 | $this->assertSame($result, $result); |
|
| 205 | $this->assertSame($calledListeners, [ |
|
| 206 | [BeforeTranslateEvent::class, 0], |
|
| 207 | [TranslateEvent::class, 0], |
|
| 208 | ]); |
|
| 209 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 210 | } |
|
| 211 | ||
| 212 | public function testReturnTranslateResultInBeforeEvents() |
|
| 213 | { |
|
| @@ 304-330 (lines=27) @@ | ||
| 301 | ]); |
|
| 302 | } |
|
| 303 | ||
| 304 | public function testDeleteUserGroupEvents() |
|
| 305 | { |
|
| 306 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 307 | BeforeDeleteUserGroupEvent::class, |
|
| 308 | DeleteUserGroupEvent::class |
|
| 309 | ); |
|
| 310 | ||
| 311 | $parameters = [ |
|
| 312 | $this->createMock(UserGroup::class), |
|
| 313 | ]; |
|
| 314 | ||
| 315 | $locations = []; |
|
| 316 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 317 | $innerServiceMock->method('deleteUserGroup')->willReturn($locations); |
|
| 318 | ||
| 319 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 320 | $result = $service->deleteUserGroup(...$parameters); |
|
| 321 | ||
| 322 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 323 | ||
| 324 | $this->assertSame($locations, $result); |
|
| 325 | $this->assertSame($calledListeners, [ |
|
| 326 | [BeforeDeleteUserGroupEvent::class, 0], |
|
| 327 | [DeleteUserGroupEvent::class, 0], |
|
| 328 | ]); |
|
| 329 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 330 | } |
|
| 331 | ||
| 332 | public function testReturnDeleteUserGroupResultInBeforeEvents() |
|
| 333 | { |
|
| @@ 462-488 (lines=27) @@ | ||
| 459 | ]); |
|
| 460 | } |
|
| 461 | ||
| 462 | public function testDeleteUserEvents() |
|
| 463 | { |
|
| 464 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 465 | BeforeDeleteUserEvent::class, |
|
| 466 | DeleteUserEvent::class |
|
| 467 | ); |
|
| 468 | ||
| 469 | $parameters = [ |
|
| 470 | $this->createMock(User::class), |
|
| 471 | ]; |
|
| 472 | ||
| 473 | $locations = []; |
|
| 474 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 475 | $innerServiceMock->method('deleteUser')->willReturn($locations); |
|
| 476 | ||
| 477 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 478 | $result = $service->deleteUser(...$parameters); |
|
| 479 | ||
| 480 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 481 | ||
| 482 | $this->assertSame($locations, $result); |
|
| 483 | $this->assertSame($calledListeners, [ |
|
| 484 | [BeforeDeleteUserEvent::class, 0], |
|
| 485 | [DeleteUserEvent::class, 0], |
|
| 486 | ]); |
|
| 487 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 488 | } |
|
| 489 | ||
| 490 | public function testReturnDeleteUserResultInBeforeEvents() |
|
| 491 | { |
|
| @@ 620-647 (lines=28) @@ | ||
| 617 | ]); |
|
| 618 | } |
|
| 619 | ||
| 620 | public function testCreateUserEvents() |
|
| 621 | { |
|
| 622 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 623 | BeforeCreateUserEvent::class, |
|
| 624 | CreateUserEvent::class |
|
| 625 | ); |
|
| 626 | ||
| 627 | $parameters = [ |
|
| 628 | $this->createMock(UserCreateStruct::class), |
|
| 629 | [], |
|
| 630 | ]; |
|
| 631 | ||
| 632 | $user = $this->createMock(User::class); |
|
| 633 | $innerServiceMock = $this->createMock(UserServiceInterface::class); |
|
| 634 | $innerServiceMock->method('createUser')->willReturn($user); |
|
| 635 | ||
| 636 | $service = new UserService($innerServiceMock, $traceableEventDispatcher); |
|
| 637 | $result = $service->createUser(...$parameters); |
|
| 638 | ||
| 639 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 640 | ||
| 641 | $this->assertSame($user, $result); |
|
| 642 | $this->assertSame($calledListeners, [ |
|
| 643 | [BeforeCreateUserEvent::class, 0], |
|
| 644 | [CreateUserEvent::class, 0], |
|
| 645 | ]); |
|
| 646 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 647 | } |
|
| 648 | ||
| 649 | public function testReturnCreateUserResultInBeforeEvents() |
|
| 650 | { |
|
| @@ 435-461 (lines=27) @@ | ||
| 432 | ]); |
|
| 433 | } |
|
| 434 | ||
| 435 | public function testCreateRoleEvents() |
|
| 436 | { |
|
| 437 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 438 | BeforeCreateRoleEvent::class, |
|
| 439 | CreateRoleEvent::class |
|
| 440 | ); |
|
| 441 | ||
| 442 | $parameters = [ |
|
| 443 | $this->createMock(RoleCreateStruct::class), |
|
| 444 | ]; |
|
| 445 | ||
| 446 | $roleDraft = $this->createMock(RoleDraft::class); |
|
| 447 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 448 | $innerServiceMock->method('createRole')->willReturn($roleDraft); |
|
| 449 | ||
| 450 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 451 | $result = $service->createRole(...$parameters); |
|
| 452 | ||
| 453 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 454 | ||
| 455 | $this->assertSame($roleDraft, $result); |
|
| 456 | $this->assertSame($calledListeners, [ |
|
| 457 | [BeforeCreateRoleEvent::class, 0], |
|
| 458 | [CreateRoleEvent::class, 0], |
|
| 459 | ]); |
|
| 460 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 461 | } |
|
| 462 | ||
| 463 | public function testReturnCreateRoleResultInBeforeEvents() |
|
| 464 | { |
|
| @@ 909-935 (lines=27) @@ | ||
| 906 | ]); |
|
| 907 | } |
|
| 908 | ||
| 909 | public function testCreateRoleDraftEvents() |
|
| 910 | { |
|
| 911 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 912 | BeforeCreateRoleDraftEvent::class, |
|
| 913 | CreateRoleDraftEvent::class |
|
| 914 | ); |
|
| 915 | ||
| 916 | $parameters = [ |
|
| 917 | $this->createMock(Role::class), |
|
| 918 | ]; |
|
| 919 | ||
| 920 | $roleDraft = $this->createMock(RoleDraft::class); |
|
| 921 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 922 | $innerServiceMock->method('createRoleDraft')->willReturn($roleDraft); |
|
| 923 | ||
| 924 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 925 | $result = $service->createRoleDraft(...$parameters); |
|
| 926 | ||
| 927 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 928 | ||
| 929 | $this->assertSame($roleDraft, $result); |
|
| 930 | $this->assertSame($calledListeners, [ |
|
| 931 | [BeforeCreateRoleDraftEvent::class, 0], |
|
| 932 | [CreateRoleDraftEvent::class, 0], |
|
| 933 | ]); |
|
| 934 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 935 | } |
|
| 936 | ||
| 937 | public function testReturnCreateRoleDraftResultInBeforeEvents() |
|
| 938 | { |
|