| @@ 2642-2687 (lines=46) @@ | ||
| 2639 | * |
|
| 2640 | * @dataProvider providerForTestLookup |
|
| 2641 | */ |
|
| 2642 | public function testLookup($prioritizedLanguageList, $showAllTranslations, $alwaysAvailable, $languageCode) |
|
| 2643 | { |
|
| 2644 | $urlAliasService = $this->getPartlyMockedURLAliasServiceService(); |
|
| 2645 | $configuration = [ |
|
| 2646 | 'prioritizedLanguageList' => $prioritizedLanguageList, |
|
| 2647 | 'showAllTranslations' => $showAllTranslations, |
|
| 2648 | ]; |
|
| 2649 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 2650 | ||
| 2651 | $this->urlAliasHandler->expects( |
|
| 2652 | $this->once() |
|
| 2653 | )->method( |
|
| 2654 | 'lookup' |
|
| 2655 | )->with( |
|
| 2656 | $this->equalTo('jedan/dva') |
|
| 2657 | )->will( |
|
| 2658 | $this->returnValue( |
|
| 2659 | new SPIUrlAlias( |
|
| 2660 | [ |
|
| 2661 | 'pathData' => [ |
|
| 2662 | [ |
|
| 2663 | 'always-available' => $alwaysAvailable, |
|
| 2664 | 'translations' => ['cro-HR' => 'jedan'], |
|
| 2665 | ], |
|
| 2666 | [ |
|
| 2667 | 'always-available' => $alwaysAvailable, |
|
| 2668 | 'translations' => [ |
|
| 2669 | 'cro-HR' => 'dva', |
|
| 2670 | 'eng-GB' => 'two', |
|
| 2671 | ], |
|
| 2672 | ], |
|
| 2673 | ], |
|
| 2674 | 'languageCodes' => ['eng-GB', 'cro-HR'], |
|
| 2675 | 'alwaysAvailable' => $alwaysAvailable, |
|
| 2676 | ] |
|
| 2677 | ) |
|
| 2678 | ) |
|
| 2679 | ); |
|
| 2680 | ||
| 2681 | $urlAlias = $urlAliasService->lookup('jedan/dva', $languageCode); |
|
| 2682 | ||
| 2683 | self::assertInstanceOf( |
|
| 2684 | 'eZ\\Publish\\API\\Repository\\Values\\Content\\URLAlias', |
|
| 2685 | $urlAlias |
|
| 2686 | ); |
|
| 2687 | } |
|
| 2688 | ||
| 2689 | public function providerForTestLookupWithSharedTranslation() |
|
| 2690 | { |
|
| @@ 2715-2764 (lines=50) @@ | ||
| 2712 | * |
|
| 2713 | * @dataProvider providerForTestLookupWithSharedTranslation |
|
| 2714 | */ |
|
| 2715 | public function testLookupWithSharedTranslation( |
|
| 2716 | $prioritizedLanguageList, |
|
| 2717 | $showAllTranslations, |
|
| 2718 | $alwaysAvailable, |
|
| 2719 | $languageCode |
|
| 2720 | ) { |
|
| 2721 | $urlAliasService = $this->getPartlyMockedURLAliasServiceService(); |
|
| 2722 | $configuration = [ |
|
| 2723 | 'prioritizedLanguageList' => $prioritizedLanguageList, |
|
| 2724 | 'showAllTranslations' => $showAllTranslations, |
|
| 2725 | ]; |
|
| 2726 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 2727 | ||
| 2728 | $this->urlAliasHandler->expects( |
|
| 2729 | $this->once() |
|
| 2730 | )->method( |
|
| 2731 | 'lookup' |
|
| 2732 | )->with( |
|
| 2733 | $this->equalTo('jedan/two') |
|
| 2734 | )->will( |
|
| 2735 | $this->returnValue( |
|
| 2736 | new SPIUrlAlias( |
|
| 2737 | [ |
|
| 2738 | 'pathData' => [ |
|
| 2739 | [ |
|
| 2740 | 'always-available' => $alwaysAvailable, |
|
| 2741 | 'translations' => [ |
|
| 2742 | 'cro-HR' => 'jedan', |
|
| 2743 | 'eng-GB' => 'jedan', |
|
| 2744 | ], |
|
| 2745 | ], |
|
| 2746 | [ |
|
| 2747 | 'always-available' => $alwaysAvailable, |
|
| 2748 | 'translations' => [ |
|
| 2749 | 'cro-HR' => 'two', |
|
| 2750 | 'eng-GB' => 'two', |
|
| 2751 | ], |
|
| 2752 | ], |
|
| 2753 | ], |
|
| 2754 | 'languageCodes' => ['eng-GB', 'cro-HR'], |
|
| 2755 | 'alwaysAvailable' => $alwaysAvailable, |
|
| 2756 | ] |
|
| 2757 | ) |
|
| 2758 | ) |
|
| 2759 | ); |
|
| 2760 | ||
| 2761 | $urlAlias = $urlAliasService->lookup('jedan/two', $languageCode); |
|
| 2762 | ||
| 2763 | self::assertInstanceOf(URLAlias::class, $urlAlias); |
|
| 2764 | } |
|
| 2765 | ||
| 2766 | /** |
|
| 2767 | * Test for the reverseLookup() method. |
|