| @@ 669-695 (lines=27) @@ | ||
| 666 | $this->assertSame($generatedLink, $this->router->generate($location, $parameters, $referenceType)); |
|
| 667 | } |
|
| 668 | ||
| 669 | public function testGenerateWithRouteObject(): void |
|
| 670 | { |
|
| 671 | $location = new Location(['id' => 54]); |
|
| 672 | $parameters = [ |
|
| 673 | 'some' => 'thing', |
|
| 674 | ]; |
|
| 675 | ||
| 676 | $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH; |
|
| 677 | $generatedLink = '/foo/bar'; |
|
| 678 | ||
| 679 | $this->urlALiasGenerator |
|
| 680 | ->expects($this->once()) |
|
| 681 | ->method('generate') |
|
| 682 | ->with($location, $parameters, $referenceType) |
|
| 683 | ->will($this->returnValue($generatedLink)); |
|
| 684 | ||
| 685 | $this->assertSame( |
|
| 686 | $generatedLink, |
|
| 687 | $this->router->generate( |
|
| 688 | '', |
|
| 689 | $parameters + [ |
|
| 690 | RouteObjectInterface::ROUTE_OBJECT => $location, |
|
| 691 | ], |
|
| 692 | $referenceType |
|
| 693 | ) |
|
| 694 | ); |
|
| 695 | } |
|
| 696 | ||
| 697 | public function testGenerateNoLocation() |
|
| 698 | { |
|
| @@ 738-758 (lines=21) @@ | ||
| 735 | ); |
|
| 736 | } |
|
| 737 | ||
| 738 | public function testGenerateWithLocationAsParameter() |
|
| 739 | { |
|
| 740 | $locationId = 123; |
|
| 741 | $location = new Location(['id' => $locationId]); |
|
| 742 | $parameters = ['some' => 'thing']; |
|
| 743 | $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH; |
|
| 744 | $generatedLink = '/foo/bar'; |
|
| 745 | $this->urlALiasGenerator |
|
| 746 | ->expects($this->once()) |
|
| 747 | ->method('generate') |
|
| 748 | ->with($location, $parameters, $referenceType) |
|
| 749 | ->will($this->returnValue($generatedLink)); |
|
| 750 | $this->assertSame( |
|
| 751 | $generatedLink, |
|
| 752 | $this->router->generate( |
|
| 753 | UrlAliasRouter::URL_ALIAS_ROUTE_NAME, |
|
| 754 | $parameters + ['location' => $location], |
|
| 755 | $referenceType |
|
| 756 | ) |
|
| 757 | ); |
|
| 758 | } |
|
| 759 | ||
| 760 | public function testGenerateWithContentId() |
|
| 761 | { |
|
| @@ 794-813 (lines=20) @@ | ||
| 791 | ); |
|
| 792 | } |
|
| 793 | ||
| 794 | public function testGenerateWithContentIdWithMissingMainLocation() |
|
| 795 | { |
|
| 796 | $this->expectException(\LogicException::class); |
|
| 797 | ||
| 798 | $contentId = 456; |
|
| 799 | $contentInfo = new ContentInfo(['id' => $contentId, 'mainLocationId' => null]); |
|
| 800 | $parameters = ['some' => 'thing']; |
|
| 801 | $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH; |
|
| 802 | $this->contentService |
|
| 803 | ->expects($this->once()) |
|
| 804 | ->method('loadContentInfo') |
|
| 805 | ->with($contentId) |
|
| 806 | ->will($this->returnValue($contentInfo)); |
|
| 807 | ||
| 808 | $this->router->generate( |
|
| 809 | UrlAliasRouter::URL_ALIAS_ROUTE_NAME, |
|
| 810 | $parameters + ['contentId' => $contentId], |
|
| 811 | $referenceType |
|
| 812 | ); |
|
| 813 | } |
|
| 814 | } |
|
| 815 | ||