| @@ 716-769 (lines=54) @@ | ||
| 713 | /** |
|
| 714 | * Test for the load() method. |
|
| 715 | */ |
|
| 716 | public function testListLocationAliasesWithShowAllTranslations() |
|
| 717 | { |
|
| 718 | $pathElement1 = [ |
|
| 719 | 'always-available' => true, |
|
| 720 | 'translations' => [ |
|
| 721 | 'cro-HR' => 'jedan', |
|
| 722 | ], |
|
| 723 | ]; |
|
| 724 | $pathElement2 = [ |
|
| 725 | 'always-available' => false, |
|
| 726 | 'translations' => [ |
|
| 727 | 'cro-HR' => 'dva', |
|
| 728 | 'eng-GB' => 'two', |
|
| 729 | ], |
|
| 730 | ]; |
|
| 731 | $pathElement3 = [ |
|
| 732 | 'always-available' => false, |
|
| 733 | 'translations' => [ |
|
| 734 | 'cro-HR' => 'tri', |
|
| 735 | 'eng-GB' => 'three', |
|
| 736 | 'ger-DE' => 'drei', |
|
| 737 | ], |
|
| 738 | ]; |
|
| 739 | $spiUrlAlias = new SPIUrlAlias( |
|
| 740 | [ |
|
| 741 | 'id' => '3', |
|
| 742 | 'pathData' => [$pathElement1, $pathElement2, $pathElement3], |
|
| 743 | 'languageCodes' => ['ger-DE'], |
|
| 744 | 'alwaysAvailable' => false, |
|
| 745 | ] |
|
| 746 | ); |
|
| 747 | $urlAliasService = $this->getPartlyMockedURLAliasServiceService(); |
|
| 748 | $configuration = [ |
|
| 749 | 'prioritizedLanguageList' => ['fre-FR'], |
|
| 750 | 'showAllTranslations' => true, |
|
| 751 | ]; |
|
| 752 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 753 | ||
| 754 | $this->urlAliasHandler |
|
| 755 | ->expects($this->once()) |
|
| 756 | ->method('listURLAliasesForLocation') |
|
| 757 | ->with( |
|
| 758 | $this->equalTo(42), |
|
| 759 | $this->equalTo(false) |
|
| 760 | ) |
|
| 761 | ->will($this->returnValue([$spiUrlAlias])); |
|
| 762 | ||
| 763 | $location = $this->getLocationStub(); |
|
| 764 | $urlAliases = $urlAliasService->listLocationAliases($location, false, null); |
|
| 765 | ||
| 766 | self::assertCount(1, $urlAliases); |
|
| 767 | self::assertInstanceOf(URLAlias::class, $urlAliases[0]); |
|
| 768 | self::assertEquals('/jedan/dva/tri', $urlAliases[0]->path); |
|
| 769 | } |
|
| 770 | ||
| 771 | /** |
|
| 772 | * Test for the load() method. |
|
| @@ 774-833 (lines=60) @@ | ||
| 771 | /** |
|
| 772 | * Test for the load() method. |
|
| 773 | */ |
|
| 774 | public function testListLocationAliasesWithShowAllTranslationsCustomConfiguration() |
|
| 775 | { |
|
| 776 | $pathElement1 = [ |
|
| 777 | 'always-available' => true, |
|
| 778 | 'translations' => [ |
|
| 779 | 'cro-HR' => 'jedan', |
|
| 780 | ], |
|
| 781 | ]; |
|
| 782 | $pathElement2 = [ |
|
| 783 | 'always-available' => false, |
|
| 784 | 'translations' => [ |
|
| 785 | 'cro-HR' => 'dva', |
|
| 786 | 'eng-GB' => 'two', |
|
| 787 | ], |
|
| 788 | ]; |
|
| 789 | $pathElement3 = [ |
|
| 790 | 'always-available' => false, |
|
| 791 | 'translations' => [ |
|
| 792 | 'cro-HR' => 'tri', |
|
| 793 | 'eng-GB' => 'three', |
|
| 794 | 'ger-DE' => 'drei', |
|
| 795 | ], |
|
| 796 | ]; |
|
| 797 | $spiUrlAlias = new SPIUrlAlias( |
|
| 798 | [ |
|
| 799 | 'id' => '3', |
|
| 800 | 'pathData' => [$pathElement1, $pathElement2, $pathElement3], |
|
| 801 | 'languageCodes' => ['ger-DE'], |
|
| 802 | 'alwaysAvailable' => false, |
|
| 803 | ] |
|
| 804 | ); |
|
| 805 | $urlAliasService = $this->getPartlyMockedURLAliasServiceService(); |
|
| 806 | $configuration = [ |
|
| 807 | 'prioritizedLanguageList' => [], |
|
| 808 | 'showAllTranslations' => false, |
|
| 809 | ]; |
|
| 810 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 811 | ||
| 812 | $this->urlAliasHandler |
|
| 813 | ->expects($this->once()) |
|
| 814 | ->method('listURLAliasesForLocation') |
|
| 815 | ->with( |
|
| 816 | $this->equalTo(42), |
|
| 817 | $this->equalTo(false) |
|
| 818 | ) |
|
| 819 | ->will($this->returnValue([$spiUrlAlias])); |
|
| 820 | ||
| 821 | $location = $this->getLocationStub(); |
|
| 822 | $urlAliases = $urlAliasService->listLocationAliases( |
|
| 823 | $location, |
|
| 824 | false, |
|
| 825 | null, |
|
| 826 | true, |
|
| 827 | ['fre-FR'] |
|
| 828 | ); |
|
| 829 | ||
| 830 | self::assertCount(1, $urlAliases); |
|
| 831 | self::assertInstanceOf(URLAlias::class, $urlAliases[0]); |
|
| 832 | self::assertEquals('/jedan/dva/tri', $urlAliases[0]->path); |
|
| 833 | } |
|
| 834 | ||
| 835 | public function providerForTestListAutogeneratedLocationAliasesEmpty() |
|
| 836 | { |
|