Code Duplication    Length = 57-57 lines in 2 locations

eZ/Bundle/EzPublishCoreBundle/Tests/Routing/UrlAliasRouterTest.php 2 locations

@@ 202-258 (lines=57) @@
199
        $this->assertEquals($expected, $this->router->matchRequest($request));
200
    }
201
202
    public function testMatchRequestLocationCaseRedirectWithRootLocation()
203
    {
204
        $rootLocationId = 123;
205
        $this->resetConfigResolver();
206
        $this->configResolver
207
            ->expects($this->any())
208
            ->method('getParameter')
209
            ->will(
210
                $this->returnValueMap(
211
                    [
212
                        ['url_alias_router', null, null, true],
213
                    ]
214
                )
215
            );
216
        $this->router->setRootLocationId($rootLocationId);
217
218
        $prefix = '/root/prefix';
219
        $this->urlALiasGenerator
220
            ->expects($this->exactly(2))
221
            ->method('getPathPrefixByRootLocationId')
222
            ->with($rootLocationId)
223
            ->will($this->returnValue($prefix));
224
        $this->urlALiasGenerator
225
            ->expects($this->once())
226
            ->method('loadLocation')
227
            ->will($this->returnValue(new Location(['contentInfo' => new ContentInfo(['id' => 456])])));
228
229
        $locationId = 789;
230
        $path = '/foo/bar';
231
        $requestedPath = '/Foo/Bar';
232
        $urlAlias = new URLAlias(
233
            [
234
                'destination' => $locationId,
235
                'path' => $prefix . $path,
236
                'type' => URLAlias::LOCATION,
237
                'isHistory' => false,
238
            ]
239
        );
240
        $this->urlAliasService
241
            ->expects($this->once())
242
            ->method('lookup')
243
            ->with($prefix . $requestedPath)
244
            ->will($this->returnValue($urlAlias));
245
246
        $expected = [
247
            '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
248
            '_controller' => UrlAliasRouter::VIEW_ACTION,
249
            'locationId' => $locationId,
250
            'contentId' => 456,
251
            'viewType' => ViewManager::VIEW_TYPE_FULL,
252
            'layout' => true,
253
            'semanticPathinfo' => $path,
254
            'needsRedirect' => true,
255
        ];
256
        $request = $this->getRequestByPathInfo($requestedPath);
257
        $this->assertEquals($expected, $this->router->matchRequest($request));
258
    }
259
260
    public function testMatchRequestLocationCaseRedirectWithRootRootLocation()
261
    {
@@ 260-316 (lines=57) @@
257
        $this->assertEquals($expected, $this->router->matchRequest($request));
258
    }
259
260
    public function testMatchRequestLocationCaseRedirectWithRootRootLocation()
261
    {
262
        $rootLocationId = 123;
263
        $this->resetConfigResolver();
264
        $this->configResolver
265
            ->expects($this->any())
266
            ->method('getParameter')
267
            ->will(
268
                $this->returnValueMap(
269
                    [
270
                        ['url_alias_router', null, null, true],
271
                    ]
272
                )
273
            );
274
        $this->router->setRootLocationId($rootLocationId);
275
276
        $prefix = '/';
277
        $this->urlALiasGenerator
278
            ->expects($this->exactly(2))
279
            ->method('getPathPrefixByRootLocationId')
280
            ->with($rootLocationId)
281
            ->will($this->returnValue($prefix));
282
283
        $locationId = 789;
284
        $path = '/foo/bar';
285
        $requestedPath = '/Foo/Bar';
286
        $urlAlias = new URLAlias(
287
            [
288
                'destination' => $locationId,
289
                'path' => $path,
290
                'type' => URLAlias::LOCATION,
291
                'isHistory' => false,
292
            ]
293
        );
294
        $this->urlAliasService
295
            ->expects($this->once())
296
            ->method('lookup')
297
            ->with($requestedPath)
298
            ->will($this->returnValue($urlAlias));
299
        $this->urlALiasGenerator
300
            ->expects($this->once())
301
            ->method('loadLocation')
302
            ->will($this->returnValue(new Location(['contentInfo' => new ContentInfo(['id' => 456])])));
303
304
        $expected = [
305
            '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
306
            '_controller' => UrlAliasRouter::VIEW_ACTION,
307
            'locationId' => $locationId,
308
            'contentId' => 456,
309
            'viewType' => ViewManager::VIEW_TYPE_FULL,
310
            'layout' => true,
311
            'semanticPathinfo' => $path,
312
            'needsRedirect' => true,
313
        ];
314
        $request = $this->getRequestByPathInfo($requestedPath);
315
        $this->assertEquals($expected, $this->router->matchRequest($request));
316
    }
317
318
    public function testMatchRequestResourceCaseRedirectWithRootLocation()
319
    {