| @@ 734-791 (lines=58) @@ | ||
| 731 | /** |
|
| 732 | * Test for the load() method. |
|
| 733 | */ |
|
| 734 | public function testListLocationAliasesWithShowAllTranslations() |
|
| 735 | { |
|
| 736 | $pathElement1 = [ |
|
| 737 | 'always-available' => true, |
|
| 738 | 'translations' => [ |
|
| 739 | 'cro-HR' => 'jedan', |
|
| 740 | ], |
|
| 741 | ]; |
|
| 742 | $pathElement2 = [ |
|
| 743 | 'always-available' => false, |
|
| 744 | 'translations' => [ |
|
| 745 | 'cro-HR' => 'dva', |
|
| 746 | 'eng-GB' => 'two', |
|
| 747 | ], |
|
| 748 | ]; |
|
| 749 | $pathElement3 = [ |
|
| 750 | 'always-available' => false, |
|
| 751 | 'translations' => [ |
|
| 752 | 'cro-HR' => 'tri', |
|
| 753 | 'eng-GB' => 'three', |
|
| 754 | 'ger-DE' => 'drei', |
|
| 755 | ], |
|
| 756 | ]; |
|
| 757 | $spiUrlAlias = new SPIUrlAlias( |
|
| 758 | [ |
|
| 759 | 'id' => '3', |
|
| 760 | 'pathData' => [$pathElement1, $pathElement2, $pathElement3], |
|
| 761 | 'languageCodes' => ['ger-DE'], |
|
| 762 | 'alwaysAvailable' => false, |
|
| 763 | ] |
|
| 764 | ); |
|
| 765 | $urlAliasService = $this->getRepository()->getURLAliasService(); |
|
| 766 | $configuration = [ |
|
| 767 | 'prioritizedLanguageList' => ['fre-FR'], |
|
| 768 | 'showAllTranslations' => true, |
|
| 769 | ]; |
|
| 770 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 771 | ||
| 772 | $urlAliasHandlerMock = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler'); |
|
| 773 | ||
| 774 | $urlAliasHandlerMock->expects( |
|
| 775 | $this->once() |
|
| 776 | )->method( |
|
| 777 | 'listURLAliasesForLocation' |
|
| 778 | )->with( |
|
| 779 | $this->equalTo(42), |
|
| 780 | $this->equalTo(false) |
|
| 781 | )->will( |
|
| 782 | $this->returnValue([$spiUrlAlias]) |
|
| 783 | ); |
|
| 784 | ||
| 785 | $location = $this->getLocationStub(); |
|
| 786 | $urlAliases = $urlAliasService->listLocationAliases($location, false, null); |
|
| 787 | ||
| 788 | self::assertCount(1, $urlAliases); |
|
| 789 | self::assertInstanceOf('eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', $urlAliases[0]); |
|
| 790 | self::assertEquals('/jedan/dva/tri', $urlAliases[0]->path); |
|
| 791 | } |
|
| 792 | ||
| 793 | /** |
|
| 794 | * Test for the load() method. |
|
| @@ 796-859 (lines=64) @@ | ||
| 793 | /** |
|
| 794 | * Test for the load() method. |
|
| 795 | */ |
|
| 796 | public function testListLocationAliasesWithShowAllTranslationsCustomConfiguration() |
|
| 797 | { |
|
| 798 | $pathElement1 = [ |
|
| 799 | 'always-available' => true, |
|
| 800 | 'translations' => [ |
|
| 801 | 'cro-HR' => 'jedan', |
|
| 802 | ], |
|
| 803 | ]; |
|
| 804 | $pathElement2 = [ |
|
| 805 | 'always-available' => false, |
|
| 806 | 'translations' => [ |
|
| 807 | 'cro-HR' => 'dva', |
|
| 808 | 'eng-GB' => 'two', |
|
| 809 | ], |
|
| 810 | ]; |
|
| 811 | $pathElement3 = [ |
|
| 812 | 'always-available' => false, |
|
| 813 | 'translations' => [ |
|
| 814 | 'cro-HR' => 'tri', |
|
| 815 | 'eng-GB' => 'three', |
|
| 816 | 'ger-DE' => 'drei', |
|
| 817 | ], |
|
| 818 | ]; |
|
| 819 | $spiUrlAlias = new SPIUrlAlias( |
|
| 820 | [ |
|
| 821 | 'id' => '3', |
|
| 822 | 'pathData' => [$pathElement1, $pathElement2, $pathElement3], |
|
| 823 | 'languageCodes' => ['ger-DE'], |
|
| 824 | 'alwaysAvailable' => false, |
|
| 825 | ] |
|
| 826 | ); |
|
| 827 | $urlAliasService = $this->getRepository()->getURLAliasService(); |
|
| 828 | $configuration = [ |
|
| 829 | 'prioritizedLanguageList' => [], |
|
| 830 | 'showAllTranslations' => false, |
|
| 831 | ]; |
|
| 832 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 833 | ||
| 834 | $urlAliasHandlerMock = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler'); |
|
| 835 | ||
| 836 | $urlAliasHandlerMock->expects( |
|
| 837 | $this->once() |
|
| 838 | )->method( |
|
| 839 | 'listURLAliasesForLocation' |
|
| 840 | )->with( |
|
| 841 | $this->equalTo(42), |
|
| 842 | $this->equalTo(false) |
|
| 843 | )->will( |
|
| 844 | $this->returnValue([$spiUrlAlias]) |
|
| 845 | ); |
|
| 846 | ||
| 847 | $location = $this->getLocationStub(); |
|
| 848 | $urlAliases = $urlAliasService->listLocationAliases( |
|
| 849 | $location, |
|
| 850 | false, |
|
| 851 | null, |
|
| 852 | true, |
|
| 853 | ['fre-FR'] |
|
| 854 | ); |
|
| 855 | ||
| 856 | self::assertCount(1, $urlAliases); |
|
| 857 | self::assertInstanceOf('eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', $urlAliases[0]); |
|
| 858 | self::assertEquals('/jedan/dva/tri', $urlAliases[0]->path); |
|
| 859 | } |
|
| 860 | ||
| 861 | public function providerForTestListAutogeneratedLocationAliasesEmpty() |
|
| 862 | { |
|