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