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