Code Duplication    Length = 20-27 lines in 3 locations

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

@@ 655-681 (lines=27) @@
652
        $this->router->generate('invalidRoute');
653
    }
654
655
    public function testGenerateWithRouteObject(): void
656
    {
657
        $location = new Location(['id' => 54]);
658
        $parameters = [
659
            'some' => 'thing',
660
        ];
661
662
        $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH;
663
        $generatedLink = '/foo/bar';
664
665
        $this->urlALiasGenerator
666
            ->expects($this->once())
667
            ->method('generate')
668
            ->with($location, $parameters, $referenceType)
669
            ->will($this->returnValue($generatedLink));
670
671
        $this->assertSame(
672
            $generatedLink,
673
            $this->router->generate(
674
                '',
675
                $parameters + [
676
                    RouteObjectInterface::ROUTE_OBJECT => $location,
677
                ],
678
                $referenceType
679
            )
680
        );
681
    }
682
683
    public function testGenerateNoLocation()
684
    {
@@ 724-744 (lines=21) @@
721
        );
722
    }
723
724
    public function testGenerateWithLocationAsParameter()
725
    {
726
        $locationId = 123;
727
        $location = new Location(['id' => $locationId]);
728
        $parameters = ['some' => 'thing'];
729
        $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH;
730
        $generatedLink = '/foo/bar';
731
        $this->urlALiasGenerator
732
            ->expects($this->once())
733
            ->method('generate')
734
            ->with($location, $parameters, $referenceType)
735
            ->will($this->returnValue($generatedLink));
736
        $this->assertSame(
737
            $generatedLink,
738
            $this->router->generate(
739
                UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
740
                $parameters + ['location' => $location],
741
                $referenceType
742
            )
743
        );
744
    }
745
746
    public function testGenerateWithContentId()
747
    {
@@ 780-799 (lines=20) @@
777
        );
778
    }
779
780
    public function testGenerateWithContentIdWithMissingMainLocation()
781
    {
782
        $this->expectException(\LogicException::class);
783
784
        $contentId = 456;
785
        $contentInfo = new ContentInfo(['id' => $contentId, 'mainLocationId' => null]);
786
        $parameters = ['some' => 'thing'];
787
        $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH;
788
        $this->contentService
789
            ->expects($this->once())
790
            ->method('loadContentInfo')
791
            ->with($contentId)
792
            ->will($this->returnValue($contentInfo));
793
794
        $this->router->generate(
795
            UrlAliasRouter::URL_ALIAS_ROUTE_NAME,
796
            $parameters + ['contentId' => $contentId],
797
            $referenceType
798
        );
799
    }
800
}
801