Code Duplication    Length = 29-31 lines in 3 locations

eZ/Publish/Core/Event/Tests/URLAliasServiceTest.php 2 locations

@@ 21-51 (lines=31) @@
18
19
class URLAliasServiceTest extends AbstractServiceTest
20
{
21
    public function testCreateGlobalUrlAliasEvents()
22
    {
23
        $traceableEventDispatcher = $this->getEventDispatcher(
24
            URLAliasEvents::BEFORE_CREATE_GLOBAL_URL_ALIAS,
25
            URLAliasEvents::CREATE_GLOBAL_URL_ALIAS
26
        );
27
28
        $parameters = [
29
            'random_value_5cff79c3183471.48198669',
30
            'random_value_5cff79c3183491.90712521',
31
            'random_value_5cff79c31834a2.27245619',
32
            'random_value_5cff79c31834b7.17763784',
33
            'random_value_5cff79c31834c3.69513526',
34
        ];
35
36
        $urlAlias = $this->createMock(URLAlias::class);
37
        $innerServiceMock = $this->createMock(URLAliasServiceInterface::class);
38
        $innerServiceMock->method('createGlobalUrlAlias')->willReturn($urlAlias);
39
40
        $service = new URLAliasService($innerServiceMock, $traceableEventDispatcher);
41
        $result = $service->createGlobalUrlAlias(...$parameters);
42
43
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
44
45
        $this->assertSame($urlAlias, $result);
46
        $this->assertSame($calledListeners, [
47
            [URLAliasEvents::BEFORE_CREATE_GLOBAL_URL_ALIAS, 0],
48
            [URLAliasEvents::CREATE_GLOBAL_URL_ALIAS, 0],
49
        ]);
50
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
51
    }
52
53
    public function testReturnCreateGlobalUrlAliasResultInBeforeEvents()
54
    {
@@ 189-219 (lines=31) @@
186
        ]);
187
    }
188
189
    public function testCreateUrlAliasEvents()
190
    {
191
        $traceableEventDispatcher = $this->getEventDispatcher(
192
            URLAliasEvents::BEFORE_CREATE_URL_ALIAS,
193
            URLAliasEvents::CREATE_URL_ALIAS
194
        );
195
196
        $parameters = [
197
            $this->createMock(Location::class),
198
            'random_value_5cff79c3184f05.03459159',
199
            'random_value_5cff79c3184f14.18292216',
200
            'random_value_5cff79c3184f24.01158164',
201
            'random_value_5cff79c3184f32.03833593',
202
        ];
203
204
        $urlAlias = $this->createMock(URLAlias::class);
205
        $innerServiceMock = $this->createMock(URLAliasServiceInterface::class);
206
        $innerServiceMock->method('createUrlAlias')->willReturn($urlAlias);
207
208
        $service = new URLAliasService($innerServiceMock, $traceableEventDispatcher);
209
        $result = $service->createUrlAlias(...$parameters);
210
211
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
212
213
        $this->assertSame($urlAlias, $result);
214
        $this->assertSame($calledListeners, [
215
            [URLAliasEvents::BEFORE_CREATE_URL_ALIAS, 0],
216
            [URLAliasEvents::CREATE_URL_ALIAS, 0],
217
        ]);
218
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
219
    }
220
221
    public function testReturnCreateUrlAliasResultInBeforeEvents()
222
    {

eZ/Publish/Core/Event/Tests/URLWildcardServiceTest.php 1 location

@@ 77-105 (lines=29) @@
74
        ]);
75
    }
76
77
    public function testCreateEvents()
78
    {
79
        $traceableEventDispatcher = $this->getEventDispatcher(
80
            URLWildcardEvents::BEFORE_CREATE,
81
            URLWildcardEvents::CREATE
82
        );
83
84
        $parameters = [
85
            'random_value_5cff79c316c1f5.58580131',
86
            'random_value_5cff79c316c223.93334332',
87
            'random_value_5cff79c316c237.08397355',
88
        ];
89
90
        $urlWildcard = $this->createMock(URLWildcard::class);
91
        $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class);
92
        $innerServiceMock->method('create')->willReturn($urlWildcard);
93
94
        $service = new URLWildcardService($innerServiceMock, $traceableEventDispatcher);
95
        $result = $service->create(...$parameters);
96
97
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
98
99
        $this->assertSame($urlWildcard, $result);
100
        $this->assertSame($calledListeners, [
101
            [URLWildcardEvents::BEFORE_CREATE, 0],
102
            [URLWildcardEvents::CREATE, 0],
103
        ]);
104
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
105
    }
106
107
    public function testReturnCreateResultInBeforeEvents()
108
    {