Code Duplication    Length = 25-27 lines in 3 locations

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

@@ 476-500 (lines=25) @@
473
        $this->router->matchRequest($request);
474
    }
475
476
    public function testMatchRequestResource()
477
    {
478
        $pathInfo = '/hello_content/hello_search';
479
        $destination = '/content/search';
480
        $urlAlias = new URLAlias(
481
            [
482
                'destination' => $destination,
483
                'path' => $pathInfo,
484
                'type' => UrlAlias::RESOURCE,
485
            ]
486
        );
487
        $request = $this->getRequestByPathInfo($pathInfo);
488
        $this->urlAliasService
489
            ->expects($this->once())
490
            ->method('lookup')
491
            ->with($pathInfo)
492
            ->will($this->returnValue($urlAlias));
493
494
        $expected = [
495
            '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
496
            'semanticPathinfo' => $destination,
497
            'needsForward' => true,
498
        ];
499
        $this->assertEquals($expected, $this->router->matchRequest($request));
500
    }
501
502
    public function testMatchRequestResourceWithRedirect()
503
    {
@@ 502-527 (lines=26) @@
499
        $this->assertEquals($expected, $this->router->matchRequest($request));
500
    }
501
502
    public function testMatchRequestResourceWithRedirect()
503
    {
504
        $pathInfo = '/hello_content/hello_search';
505
        $destination = '/content/search';
506
        $urlAlias = new URLAlias(
507
            [
508
                'destination' => $destination,
509
                'path' => $pathInfo,
510
                'type' => UrlAlias::RESOURCE,
511
                'forward' => true,
512
            ]
513
        );
514
        $request = $this->getRequestByPathInfo($pathInfo);
515
        $this->urlAliasService
516
            ->expects($this->once())
517
            ->method('lookup')
518
            ->with($pathInfo)
519
            ->will($this->returnValue($urlAlias));
520
521
        $expected = [
522
            '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
523
            'needsRedirect' => true,
524
            'semanticPathinfo' => $destination,
525
        ];
526
        $this->assertEquals($expected, $this->router->matchRequest($request));
527
    }
528
529
    public function testMatchRequestResourceWithCaseRedirect()
530
    {
@@ 566-592 (lines=27) @@
563
     * Tests that forwarding custom alias will redirect to the resource destination rather than
564
     * to the case-corrected alias.
565
     */
566
    public function testMatchRequestResourceCaseIncorrectWithForwardRedirect()
567
    {
568
        $pathInfo = '/heLLo_contEnt/hEllo_SEarch';
569
        $urlAliasPath = '/hello_content/hello_search';
570
        $destination = '/content/search';
571
        $urlAlias = new URLAlias(
572
            [
573
                'destination' => $destination,
574
                'path' => $urlAliasPath,
575
                'type' => UrlAlias::RESOURCE,
576
                'forward' => true,
577
            ]
578
        );
579
        $request = $this->getRequestByPathInfo($pathInfo);
580
        $this->urlAliasService
581
            ->expects($this->once())
582
            ->method('lookup')
583
            ->with($pathInfo)
584
            ->will($this->returnValue($urlAlias));
585
586
        $expected = [
587
            '_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
588
            'semanticPathinfo' => $destination,
589
            'needsRedirect' => true,
590
        ];
591
        $this->assertEquals($expected, $this->router->matchRequest($request));
592
    }
593
594
    public function testMatchRequestVirtual()
595
    {