| @@ 24-54 (lines=31) @@ | ||
| 21 | ||
| 22 | class URLAliasServiceTest extends AbstractServiceTest |
|
| 23 | { |
|
| 24 | public function testCreateGlobalUrlAliasEvents() |
|
| 25 | { |
|
| 26 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 27 | BeforeCreateGlobalUrlAliasEventInterface::class, |
|
| 28 | CreateGlobalUrlAliasEventInterface::class |
|
| 29 | ); |
|
| 30 | ||
| 31 | $parameters = [ |
|
| 32 | 'random_value_5cff79c3183471.48198669', |
|
| 33 | 'random_value_5cff79c3183491.90712521', |
|
| 34 | 'random_value_5cff79c31834a2.27245619', |
|
| 35 | 'random_value_5cff79c31834b7.17763784', |
|
| 36 | 'random_value_5cff79c31834c3.69513526', |
|
| 37 | ]; |
|
| 38 | ||
| 39 | $urlAlias = $this->createMock(URLAlias::class); |
|
| 40 | $innerServiceMock = $this->createMock(URLAliasServiceInterface::class); |
|
| 41 | $innerServiceMock->method('createGlobalUrlAlias')->willReturn($urlAlias); |
|
| 42 | ||
| 43 | $service = new URLAliasService($innerServiceMock, $traceableEventDispatcher); |
|
| 44 | $result = $service->createGlobalUrlAlias(...$parameters); |
|
| 45 | ||
| 46 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 47 | ||
| 48 | $this->assertSame($urlAlias, $result); |
|
| 49 | $this->assertSame($calledListeners, [ |
|
| 50 | [BeforeCreateGlobalUrlAliasEventInterface::class, 0], |
|
| 51 | [CreateGlobalUrlAliasEventInterface::class, 0], |
|
| 52 | ]); |
|
| 53 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 54 | } |
|
| 55 | ||
| 56 | public function testReturnCreateGlobalUrlAliasResultInBeforeEvents() |
|
| 57 | { |
|
| @@ 192-222 (lines=31) @@ | ||
| 189 | ]); |
|
| 190 | } |
|
| 191 | ||
| 192 | public function testCreateUrlAliasEvents() |
|
| 193 | { |
|
| 194 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 195 | BeforeCreateUrlAliasEventInterface::class, |
|
| 196 | CreateUrlAliasEventInterface::class |
|
| 197 | ); |
|
| 198 | ||
| 199 | $parameters = [ |
|
| 200 | $this->createMock(Location::class), |
|
| 201 | 'random_value_5cff79c3184f05.03459159', |
|
| 202 | 'random_value_5cff79c3184f14.18292216', |
|
| 203 | 'random_value_5cff79c3184f24.01158164', |
|
| 204 | 'random_value_5cff79c3184f32.03833593', |
|
| 205 | ]; |
|
| 206 | ||
| 207 | $urlAlias = $this->createMock(URLAlias::class); |
|
| 208 | $innerServiceMock = $this->createMock(URLAliasServiceInterface::class); |
|
| 209 | $innerServiceMock->method('createUrlAlias')->willReturn($urlAlias); |
|
| 210 | ||
| 211 | $service = new URLAliasService($innerServiceMock, $traceableEventDispatcher); |
|
| 212 | $result = $service->createUrlAlias(...$parameters); |
|
| 213 | ||
| 214 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 215 | ||
| 216 | $this->assertSame($urlAlias, $result); |
|
| 217 | $this->assertSame($calledListeners, [ |
|
| 218 | [BeforeCreateUrlAliasEventInterface::class, 0], |
|
| 219 | [CreateUrlAliasEventInterface::class, 0], |
|
| 220 | ]); |
|
| 221 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 222 | } |
|
| 223 | ||
| 224 | public function testReturnCreateUrlAliasResultInBeforeEvents() |
|
| 225 | { |
|
| @@ 79-107 (lines=29) @@ | ||
| 76 | ]); |
|
| 77 | } |
|
| 78 | ||
| 79 | public function testCreateEvents() |
|
| 80 | { |
|
| 81 | $traceableEventDispatcher = $this->getEventDispatcher( |
|
| 82 | BeforeCreateEventInterface::class, |
|
| 83 | CreateEventInterface::class |
|
| 84 | ); |
|
| 85 | ||
| 86 | $parameters = [ |
|
| 87 | 'random_value_5cff79c316c1f5.58580131', |
|
| 88 | 'random_value_5cff79c316c223.93334332', |
|
| 89 | 'random_value_5cff79c316c237.08397355', |
|
| 90 | ]; |
|
| 91 | ||
| 92 | $urlWildcard = $this->createMock(URLWildcard::class); |
|
| 93 | $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class); |
|
| 94 | $innerServiceMock->method('create')->willReturn($urlWildcard); |
|
| 95 | ||
| 96 | $service = new URLWildcardService($innerServiceMock, $traceableEventDispatcher); |
|
| 97 | $result = $service->create(...$parameters); |
|
| 98 | ||
| 99 | $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners()); |
|
| 100 | ||
| 101 | $this->assertSame($urlWildcard, $result); |
|
| 102 | $this->assertSame($calledListeners, [ |
|
| 103 | [BeforeCreateEventInterface::class, 0], |
|
| 104 | [CreateEventInterface::class, 0], |
|
| 105 | ]); |
|
| 106 | $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners()); |
|
| 107 | } |
|
| 108 | ||
| 109 | public function testReturnCreateResultInBeforeEvents() |
|
| 110 | { |
|