Code Duplication    Length = 35-37 lines in 3 locations

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

@@ 56-92 (lines=37) @@
53
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
54
    }
55
56
    public function testReturnCreateGlobalUrlAliasResultInBeforeEvents()
57
    {
58
        $traceableEventDispatcher = $this->getEventDispatcher(
59
            BeforeCreateGlobalUrlAliasEventInterface::class,
60
            CreateGlobalUrlAliasEventInterface::class
61
        );
62
63
        $parameters = [
64
            'random_value_5cff79c3183999.45723962',
65
            'random_value_5cff79c31839a0.16919746',
66
            'random_value_5cff79c31839b6.04657069',
67
            'random_value_5cff79c31839c8.99027893',
68
            'random_value_5cff79c31839d9.22502123',
69
        ];
70
71
        $urlAlias = $this->createMock(URLAlias::class);
72
        $eventUrlAlias = $this->createMock(URLAlias::class);
73
        $innerServiceMock = $this->createMock(URLAliasServiceInterface::class);
74
        $innerServiceMock->method('createGlobalUrlAlias')->willReturn($urlAlias);
75
76
        $traceableEventDispatcher->addListener(BeforeCreateGlobalUrlAliasEventInterface::class, function (BeforeCreateGlobalUrlAliasEventInterface $event) use ($eventUrlAlias) {
77
            $event->setUrlAlias($eventUrlAlias);
78
        }, 10);
79
80
        $service = new URLAliasService($innerServiceMock, $traceableEventDispatcher);
81
        $result = $service->createGlobalUrlAlias(...$parameters);
82
83
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
84
85
        $this->assertSame($eventUrlAlias, $result);
86
        $this->assertSame($calledListeners, [
87
            [BeforeCreateGlobalUrlAliasEventInterface::class, 10],
88
            [BeforeCreateGlobalUrlAliasEventInterface::class, 0],
89
            [CreateGlobalUrlAliasEventInterface::class, 0],
90
        ]);
91
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
92
    }
93
94
    public function testCreateGlobalUrlAliasStopPropagationInBeforeEvents()
95
    {
@@ 224-260 (lines=37) @@
221
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
222
    }
223
224
    public function testReturnCreateUrlAliasResultInBeforeEvents()
225
    {
226
        $traceableEventDispatcher = $this->getEventDispatcher(
227
            BeforeCreateUrlAliasEventInterface::class,
228
            CreateUrlAliasEventInterface::class
229
        );
230
231
        $parameters = [
232
            $this->createMock(Location::class),
233
            'random_value_5cff79c3184fd7.07408772',
234
            'random_value_5cff79c3184fe2.98616568',
235
            'random_value_5cff79c3184ff0.62652505',
236
            'random_value_5cff79c3185003.87499400',
237
        ];
238
239
        $urlAlias = $this->createMock(URLAlias::class);
240
        $eventUrlAlias = $this->createMock(URLAlias::class);
241
        $innerServiceMock = $this->createMock(URLAliasServiceInterface::class);
242
        $innerServiceMock->method('createUrlAlias')->willReturn($urlAlias);
243
244
        $traceableEventDispatcher->addListener(BeforeCreateUrlAliasEventInterface::class, function (BeforeCreateUrlAliasEventInterface $event) use ($eventUrlAlias) {
245
            $event->setUrlAlias($eventUrlAlias);
246
        }, 10);
247
248
        $service = new URLAliasService($innerServiceMock, $traceableEventDispatcher);
249
        $result = $service->createUrlAlias(...$parameters);
250
251
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
252
253
        $this->assertSame($eventUrlAlias, $result);
254
        $this->assertSame($calledListeners, [
255
            [BeforeCreateUrlAliasEventInterface::class, 10],
256
            [BeforeCreateUrlAliasEventInterface::class, 0],
257
            [CreateUrlAliasEventInterface::class, 0],
258
        ]);
259
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
260
    }
261
262
    public function testCreateUrlAliasStopPropagationInBeforeEvents()
263
    {

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

@@ 109-143 (lines=35) @@
106
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
107
    }
108
109
    public function testReturnCreateResultInBeforeEvents()
110
    {
111
        $traceableEventDispatcher = $this->getEventDispatcher(
112
            BeforeCreateEventInterface::class,
113
            CreateEventInterface::class
114
        );
115
116
        $parameters = [
117
            'random_value_5cff79c316c2d5.26653678',
118
            'random_value_5cff79c316c2e7.55400833',
119
            'random_value_5cff79c316c2f8.59874187',
120
        ];
121
122
        $urlWildcard = $this->createMock(URLWildcard::class);
123
        $eventUrlWildcard = $this->createMock(URLWildcard::class);
124
        $innerServiceMock = $this->createMock(URLWildcardServiceInterface::class);
125
        $innerServiceMock->method('create')->willReturn($urlWildcard);
126
127
        $traceableEventDispatcher->addListener(BeforeCreateEventInterface::class, function (BeforeCreateEventInterface $event) use ($eventUrlWildcard) {
128
            $event->setUrlWildcard($eventUrlWildcard);
129
        }, 10);
130
131
        $service = new URLWildcardService($innerServiceMock, $traceableEventDispatcher);
132
        $result = $service->create(...$parameters);
133
134
        $calledListeners = $this->getListenersStack($traceableEventDispatcher->getCalledListeners());
135
136
        $this->assertSame($eventUrlWildcard, $result);
137
        $this->assertSame($calledListeners, [
138
            [BeforeCreateEventInterface::class, 10],
139
            [BeforeCreateEventInterface::class, 0],
140
            [CreateEventInterface::class, 0],
141
        ]);
142
        $this->assertSame([], $traceableEventDispatcher->getNotCalledListeners());
143
    }
144
145
    public function testCreateStopPropagationInBeforeEvents()
146
    {