| @@ 49-75 (lines=27) @@ | ||
| 46 | ||
| 47 | class ContentServiceTest extends AbstractServiceTest |
|
| 48 | { |
|
| 49 | public function testDeleteContentEvents() |
|
| 50 | { |
|
| 51 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 52 | BeforeDeleteContentEventInterface::class, |
|
| 53 | DeleteContentEventInterface::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 | [BeforeDeleteContentEventInterface::class, 0], |
|
| 72 | [DeleteContentEventInterface::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 | BeforeCreateContentEventInterface::class, |
|
| 418 | CreateContentEventInterface::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 | [BeforeCreateContentEventInterface::class, 0], |
|
| 438 | [CreateContentEventInterface::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 | BeforePublishVersionEventInterface::class, |
|
| 897 | PublishVersionEventInterface::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 | [BeforePublishVersionEventInterface::class, 0], |
|
| 917 | [PublishVersionEventInterface::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 | BeforeCreateContentTypeDraftEventInterface::class, |
|
| 175 | CreateContentTypeDraftEventInterface::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 | [BeforeCreateContentTypeDraftEventInterface::class, 0], |
|
| 194 | [CreateContentTypeDraftEventInterface::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 | BeforeCreateContentTypeGroupEventInterface::class, |
|
| 274 | CreateContentTypeGroupEventInterface::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 | [BeforeCreateContentTypeGroupEventInterface::class, 0], |
|
| 293 | [CreateContentTypeGroupEventInterface::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 | BeforeCreateContentTypeEventInterface::class, |
|
| 432 | CreateContentTypeEventInterface::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 | [BeforeCreateContentTypeEventInterface::class, 0], |
|
| 452 | [CreateContentTypeEventInterface::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 | BeforeRemoveContentTypeTranslationEventInterface::class, |
|
| 534 | RemoveContentTypeTranslationEventInterface::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 | [BeforeRemoveContentTypeTranslationEventInterface::class, 0], |
|
| 554 | [RemoveContentTypeTranslationEventInterface::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 | BeforeCreateLanguageEventInterface::class, |
|
| 87 | CreateLanguageEventInterface::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 | [BeforeCreateLanguageEventInterface::class, 0], |
|
| 106 | [CreateLanguageEventInterface::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 | BeforeUpdateLanguageNameEventInterface::class, |
|
| 186 | UpdateLanguageNameEventInterface::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 | [BeforeUpdateLanguageNameEventInterface::class, 0], |
|
| 206 | [UpdateLanguageNameEventInterface::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 | BeforeDisableLanguageEventInterface::class, |
|
| 288 | DisableLanguageEventInterface::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 | [BeforeDisableLanguageEventInterface::class, 0], |
|
| 307 | [DisableLanguageEventInterface::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 | BeforeEnableLanguageEventInterface::class, |
|
| 387 | EnableLanguageEventInterface::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 | [BeforeEnableLanguageEventInterface::class, 0], |
|
| 406 | [EnableLanguageEventInterface::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 | BeforeUnhideLocationEventInterface::class, |
|
| 197 | UnhideLocationEventInterface::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 | [BeforeUnhideLocationEventInterface::class, 0], |
|
| 216 | [UnhideLocationEventInterface::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 | BeforeHideLocationEventInterface::class, |
|
| 296 | HideLocationEventInterface::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 | [BeforeHideLocationEventInterface::class, 0], |
|
| 315 | [HideLocationEventInterface::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 | BeforeCreateNotificationEventInterface::class, |
|
| 26 | CreateNotificationEventInterface::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 | [BeforeCreateNotificationEventInterface::class, 0], |
|
| 45 | [CreateNotificationEventInterface::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 | BeforeCreateObjectStateGroupEventInterface::class, |
|
| 102 | CreateObjectStateGroupEventInterface::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 | [BeforeCreateObjectStateGroupEventInterface::class, 0], |
|
| 121 | [CreateObjectStateGroupEventInterface::class, 0], |
|
| 122 | ]); |
|
| 123 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function testReturnCreateObjectStateGroupResultInBeforeEvents() |
|
| 127 | { |
|
| @@ 768-794 (lines=27) @@ | ||
| 765 | ]); |
|
| 766 | } |
|
| 767 | ||
| 768 | public function testCreateRoleEvents() |
|
| 769 | { |
|
| 770 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 771 | BeforeCreateRoleEventInterface::class, |
|
| 772 | CreateRoleEventInterface::class |
|
| 773 | ); |
|
| 774 | ||
| 775 | $parameters = [ |
|
| 776 | $this->createMock(RoleCreateStruct::class), |
|
| 777 | ]; |
|
| 778 | ||
| 779 | $roleDraft = $this->createMock(RoleDraft::class); |
|
| 780 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 781 | $innerServiceMock->method('createRole')->willReturn($roleDraft); |
|
| 782 | ||
| 783 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 784 | $result = $service->createRole(...$parameters); |
|
| 785 | ||
| 786 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 787 | ||
| 788 | $this->assertSame($roleDraft, $result); |
|
| 789 | $this->assertSame($calledListeners, [ |
|
| 790 | [BeforeCreateRoleEventInterface::class, 0], |
|
| 791 | [CreateRoleEventInterface::class, 0], |
|
| 792 | ]); |
|
| 793 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 794 | } |
|
| 795 | ||
| 796 | public function testReturnCreateRoleResultInBeforeEvents() |
|
| 797 | { |
|
| @@ 1242-1268 (lines=27) @@ | ||
| 1239 | ]); |
|
| 1240 | } |
|
| 1241 | ||
| 1242 | public function testCreateRoleDraftEvents() |
|
| 1243 | { |
|
| 1244 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 1245 | BeforeCreateRoleDraftEventInterface::class, |
|
| 1246 | CreateRoleDraftEventInterface::class |
|
| 1247 | ); |
|
| 1248 | ||
| 1249 | $parameters = [ |
|
| 1250 | $this->createMock(Role::class), |
|
| 1251 | ]; |
|
| 1252 | ||
| 1253 | $roleDraft = $this->createMock(RoleDraft::class); |
|
| 1254 | $innerServiceMock = $this->createMock(RoleServiceInterface::class); |
|
| 1255 | $innerServiceMock->method('createRoleDraft')->willReturn($roleDraft); |
|
| 1256 | ||
| 1257 | $service = new RoleService($innerServiceMock, $traceableEventDispatcher); |
|
| 1258 | $result = $service->createRoleDraft(...$parameters); |
|
| 1259 | ||
| 1260 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 1261 | ||
| 1262 | $this->assertSame($roleDraft, $result); |
|
| 1263 | $this->assertSame($calledListeners, [ |
|
| 1264 | [BeforeCreateRoleDraftEventInterface::class, 0], |
|
| 1265 | [CreateRoleDraftEventInterface::class, 0], |
|
| 1266 | ]); |
|
| 1267 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 1268 | } |
|
| 1269 | ||
| 1270 | public function testReturnCreateRoleDraftResultInBeforeEvents() |
|
| 1271 | { |
|
| @@ 306-332 (lines=27) @@ | ||
| 303 | ]); |
|
| 304 | } |
|
| 305 | ||
| 306 | public function testCreateSectionEvents() |
|
| 307 | { |
|
| 308 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 309 | BeforeCreateSectionEventInterface::class, |
|
| 310 | CreateSectionEventInterface::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 | [BeforeCreateSectionEventInterface::class, 0], |
|
| 329 | [CreateSectionEventInterface::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 | BeforeEmptyTrashEventInterface::class, |
|
| 30 | EmptyTrashEventInterface::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 | [BeforeEmptyTrashEventInterface::class, 0], |
|
| 48 | [EmptyTrashEventInterface::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 | BeforeTrashEventInterface::class, |
|
| 126 | TrashEventInterface::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 | [BeforeTrashEventInterface::class, 0], |
|
| 145 | [TrashEventInterface::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 | BeforeDeleteTrashItemEventInterface::class, |
|
| 327 | DeleteTrashItemEventInterface::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 | [BeforeDeleteTrashItemEventInterface::class, 0], |
|
| 346 | [DeleteTrashItemEventInterface::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 | BeforeTranslateEventInterface::class, |
|
| 188 | TranslateEventInterface::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 | [BeforeTranslateEventInterface::class, 0], |
|
| 207 | [TranslateEventInterface::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 | BeforeDeleteUserGroupEventInterface::class, |
|
| 308 | DeleteUserGroupEventInterface::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 | [BeforeDeleteUserGroupEventInterface::class, 0], |
|
| 327 | [DeleteUserGroupEventInterface::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 | BeforeDeleteUserEventInterface::class, |
|
| 466 | DeleteUserEventInterface::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 | [BeforeDeleteUserEventInterface::class, 0], |
|
| 485 | [DeleteUserEventInterface::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 | BeforeCreateUserEventInterface::class, |
|
| 624 | CreateUserEventInterface::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 | [BeforeCreateUserEventInterface::class, 0], |
|
| 644 | [CreateUserEventInterface::class, 0], |
|
| 645 | ]); |
|
| 646 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 647 | } |
|
| 648 | ||
| 649 | public function testReturnCreateUserResultInBeforeEvents() |
|
| 650 | { |
|