Code Duplication    Length = 41-42 lines in 3 locations

eZ/Publish/Core/MVC/Symfony/Routing/Tests/UrlAliasRouterTest.php 3 locations

@@ 206-247 (lines=42) @@
203
        $this->assertSame($destinationId, $request->attributes->get('locationId'));
204
    }
205
206
    public function testMatchRequestLocationWithCaseRedirect()
207
    {
208
        $pathInfo = '/Foo/bAR';
209
        $urlAliasPath = '/foo/bar';
210
        $destinationId = 123;
211
        $urlAlias = new URLAlias(
212
            [
213
                'path' => $urlAliasPath,
214
                'type' => UrlAlias::LOCATION,
215
                'destination' => $destinationId,
216
                'isHistory' => false,
217
            ]
218
        );
219
        $request = $this->getRequestByPathInfo($pathInfo);
220
        $this->urlALiasGenerator
221
            ->expects($this->once())
222
            ->method('isUriPrefixExcluded')
223
            ->with($pathInfo)
224
            ->will($this->returnValue(false));
225
        $this->urlAliasService
226
            ->expects($this->once())
227
            ->method('lookup')
228
            ->with($pathInfo)
229
            ->will($this->returnValue($urlAlias));
230
        $this->urlALiasGenerator
231
            ->expects($this->once())
232
            ->method('loadLocation')
233
            ->will($this->returnValue(new Location(['contentInfo' => new ContentInfo(['id' => 456])])));
234
235
        $expected = [
236
            '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
237
            '_controller' => UrlAliasRouter::VIEW_ACTION,
238
            'locationId' => $destinationId,
239
            'contentId' => 456,
240
            'viewType' => ViewManager::VIEW_TYPE_FULL,
241
            'layout' => true,
242
        ];
243
        $this->assertEquals($expected, $this->router->matchRequest($request));
244
        $this->assertTrue($request->attributes->get('needsRedirect'));
245
        $this->assertSame($urlAliasPath, $request->attributes->get('semanticPathinfo'));
246
        $this->assertSame($destinationId, $request->attributes->get('locationId'));
247
    }
248
249
    public function testMatchRequestLocationWrongCaseUriPrefixExcluded()
250
    {
@@ 249-290 (lines=42) @@
246
        $this->assertSame($destinationId, $request->attributes->get('locationId'));
247
    }
248
249
    public function testMatchRequestLocationWrongCaseUriPrefixExcluded()
250
    {
251
        $pathInfo = '/Foo/bAR';
252
        $urlAliasPath = '/foo/bar';
253
        $destinationId = 123;
254
        $urlAlias = new URLAlias(
255
            [
256
                'path' => $urlAliasPath,
257
                'type' => UrlAlias::LOCATION,
258
                'destination' => $destinationId,
259
                'isHistory' => false,
260
            ]
261
        );
262
        $request = $this->getRequestByPathInfo($pathInfo);
263
        $this->urlALiasGenerator
264
            ->expects($this->once())
265
            ->method('isUriPrefixExcluded')
266
            ->with($pathInfo)
267
            ->will($this->returnValue(true));
268
        $this->urlAliasService
269
            ->expects($this->once())
270
            ->method('lookup')
271
            ->with($pathInfo)
272
            ->will($this->returnValue($urlAlias));
273
        $this->urlALiasGenerator
274
            ->expects($this->once())
275
            ->method('loadLocation')
276
            ->will($this->returnValue(new Location(['contentInfo' => new ContentInfo(['id' => 456])])));
277
278
        $expected = [
279
            '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
280
            '_controller' => UrlAliasRouter::VIEW_ACTION,
281
            'contentId' => 456,
282
            'locationId' => $destinationId,
283
            'viewType' => ViewManager::VIEW_TYPE_FULL,
284
            'layout' => true,
285
        ];
286
        $this->assertEquals($expected, $this->router->matchRequest($request));
287
        $this->assertTrue($request->attributes->has('needsRedirect'));
288
        $this->assertSame($urlAliasPath, $request->attributes->get('semanticPathinfo'));
289
        $this->assertSame($destinationId, $request->attributes->get('locationId'));
290
    }
291
292
    public function testMatchRequestLocationCorrectCaseUriPrefixExcluded()
293
    {
@@ 292-332 (lines=41) @@
289
        $this->assertSame($destinationId, $request->attributes->get('locationId'));
290
    }
291
292
    public function testMatchRequestLocationCorrectCaseUriPrefixExcluded()
293
    {
294
        $pathInfo = $urlAliasPath = '/foo/bar';
295
        $destinationId = 123;
296
        $urlAlias = new URLAlias(
297
            [
298
                'path' => $urlAliasPath,
299
                'type' => UrlAlias::LOCATION,
300
                'destination' => $destinationId,
301
                'isHistory' => false,
302
            ]
303
        );
304
        $request = $this->getRequestByPathInfo($pathInfo);
305
        $this->urlALiasGenerator
306
            ->expects($this->once())
307
            ->method('isUriPrefixExcluded')
308
            ->with($pathInfo)
309
            ->will($this->returnValue(true));
310
        $this->urlAliasService
311
            ->expects($this->once())
312
            ->method('lookup')
313
            ->with($pathInfo)
314
            ->will($this->returnValue($urlAlias));
315
        $this->urlALiasGenerator
316
            ->expects($this->once())
317
            ->method('loadLocation')
318
            ->will($this->returnValue(new Location(['contentInfo' => new ContentInfo(['id' => 456])])));
319
320
        $expected = [
321
            '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
322
            '_controller' => UrlAliasRouter::VIEW_ACTION,
323
            'locationId' => $destinationId,
324
            'contentId' => 456,
325
            'viewType' => ViewManager::VIEW_TYPE_FULL,
326
            'layout' => true,
327
        ];
328
        $this->assertEquals($expected, $this->router->matchRequest($request));
329
        $this->assertFalse($request->attributes->has('needsRedirect'));
330
        $this->assertSame($pathInfo, $request->attributes->get('semanticPathinfo'));
331
        $this->assertSame($destinationId, $request->attributes->get('locationId'));
332
    }
333
334
    public function testMatchRequestLocationHistory()
335
    {