| @@ 667-707 (lines=41) @@ | ||
| 664 | * |
|
| 665 | * @dataProvider providerForTestListAutogeneratedLocationAliasesPath |
|
| 666 | */ |
|
| 667 | public function testListAutogeneratedLocationAliasesPath($spiUrlAliases, $prioritizedLanguageCodes, $paths) |
|
| 668 | { |
|
| 669 | $urlAliasService = $this->getRepository()->getURLAliasService(); |
|
| 670 | $configuration = array( |
|
| 671 | 'prioritizedLanguageList' => $prioritizedLanguageCodes, |
|
| 672 | 'showAllTranslations' => false, |
|
| 673 | ); |
|
| 674 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 675 | ||
| 676 | $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler'); |
|
| 677 | $urlAliasHandler->expects( |
|
| 678 | $this->once() |
|
| 679 | )->method( |
|
| 680 | 'listURLAliasesForLocation' |
|
| 681 | )->with( |
|
| 682 | $this->equalTo(42), |
|
| 683 | $this->equalTo(false) |
|
| 684 | )->will( |
|
| 685 | $this->returnValue($spiUrlAliases) |
|
| 686 | ); |
|
| 687 | ||
| 688 | $location = $this->getLocationStub(); |
|
| 689 | $urlAliases = $urlAliasService->listLocationAliases($location, false, null); |
|
| 690 | ||
| 691 | self::assertEquals( |
|
| 692 | count($paths), |
|
| 693 | count($urlAliases) |
|
| 694 | ); |
|
| 695 | ||
| 696 | foreach ($urlAliases as $index => $urlAlias) { |
|
| 697 | $pathKeys = array_keys($paths); |
|
| 698 | self::assertEquals( |
|
| 699 | $paths[$pathKeys[$index]], |
|
| 700 | $urlAlias->path |
|
| 701 | ); |
|
| 702 | self::assertEquals( |
|
| 703 | array($pathKeys[$index]), |
|
| 704 | $urlAlias->languageCodes |
|
| 705 | ); |
|
| 706 | } |
|
| 707 | } |
|
| 708 | ||
| 709 | /** |
|
| 710 | * Test for the listLocationAliases() method. |
|
| @@ 714-763 (lines=50) @@ | ||
| 711 | * |
|
| 712 | * @dataProvider providerForTestListAutogeneratedLocationAliasesPath |
|
| 713 | */ |
|
| 714 | public function testListAutogeneratedLocationAliasesPathCustomConfiguration( |
|
| 715 | $spiUrlAliases, |
|
| 716 | $prioritizedLanguageCodes, |
|
| 717 | $paths |
|
| 718 | ) { |
|
| 719 | $urlAliasService = $this->getRepository()->getURLAliasService(); |
|
| 720 | $configuration = array( |
|
| 721 | 'prioritizedLanguageList' => array(), |
|
| 722 | 'showAllTranslations' => false, |
|
| 723 | ); |
|
| 724 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 725 | ||
| 726 | $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler'); |
|
| 727 | $urlAliasHandler->expects( |
|
| 728 | $this->once() |
|
| 729 | )->method( |
|
| 730 | 'listURLAliasesForLocation' |
|
| 731 | )->with( |
|
| 732 | $this->equalTo(42), |
|
| 733 | $this->equalTo(false) |
|
| 734 | )->will( |
|
| 735 | $this->returnValue($spiUrlAliases) |
|
| 736 | ); |
|
| 737 | ||
| 738 | $location = $this->getLocationStub(); |
|
| 739 | $urlAliases = $urlAliasService->listLocationAliases( |
|
| 740 | $location, |
|
| 741 | false, |
|
| 742 | null, |
|
| 743 | false, |
|
| 744 | $prioritizedLanguageCodes |
|
| 745 | ); |
|
| 746 | ||
| 747 | self::assertEquals( |
|
| 748 | count($paths), |
|
| 749 | count($urlAliases) |
|
| 750 | ); |
|
| 751 | ||
| 752 | foreach ($urlAliases as $index => $urlAlias) { |
|
| 753 | $pathKeys = array_keys($paths); |
|
| 754 | self::assertEquals( |
|
| 755 | $paths[$pathKeys[$index]], |
|
| 756 | $urlAlias->path |
|
| 757 | ); |
|
| 758 | self::assertEquals( |
|
| 759 | array($pathKeys[$index]), |
|
| 760 | $urlAlias->languageCodes |
|
| 761 | ); |
|
| 762 | } |
|
| 763 | } |
|
| 764 | ||
| 765 | /** |
|
| 766 | * Test for the load() method. |
|