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