| @@ 627-667 (lines=41) @@ | ||
| 624 | * |
|
| 625 | * @dataProvider providerForTestListAutogeneratedLocationAliasesPath |
|
| 626 | */ |
|
| 627 | public function testListAutogeneratedLocationAliasesPath($spiUrlAliases, $prioritizedLanguageCodes, $paths) |
|
| 628 | { |
|
| 629 | $urlAliasService = $this->getRepository()->getURLAliasService(); |
|
| 630 | $configuration = [ |
|
| 631 | 'prioritizedLanguageList' => $prioritizedLanguageCodes, |
|
| 632 | 'showAllTranslations' => false, |
|
| 633 | ]; |
|
| 634 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 635 | ||
| 636 | $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler'); |
|
| 637 | $urlAliasHandler->expects( |
|
| 638 | $this->once() |
|
| 639 | )->method( |
|
| 640 | 'listURLAliasesForLocation' |
|
| 641 | )->with( |
|
| 642 | $this->equalTo(42), |
|
| 643 | $this->equalTo(false) |
|
| 644 | )->will( |
|
| 645 | $this->returnValue($spiUrlAliases) |
|
| 646 | ); |
|
| 647 | ||
| 648 | $location = $this->getLocationStub(); |
|
| 649 | $urlAliases = $urlAliasService->listLocationAliases($location, false, null); |
|
| 650 | ||
| 651 | self::assertEquals( |
|
| 652 | count($paths), |
|
| 653 | count($urlAliases) |
|
| 654 | ); |
|
| 655 | ||
| 656 | foreach ($urlAliases as $index => $urlAlias) { |
|
| 657 | $pathKeys = array_keys($paths); |
|
| 658 | self::assertEquals( |
|
| 659 | $paths[$pathKeys[$index]], |
|
| 660 | $urlAlias->path |
|
| 661 | ); |
|
| 662 | self::assertEquals( |
|
| 663 | [$pathKeys[$index]], |
|
| 664 | $urlAlias->languageCodes |
|
| 665 | ); |
|
| 666 | } |
|
| 667 | } |
|
| 668 | ||
| 669 | /** |
|
| 670 | * Test for the listLocationAliases() method. |
|
| @@ 674-723 (lines=50) @@ | ||
| 671 | * |
|
| 672 | * @dataProvider providerForTestListAutogeneratedLocationAliasesPath |
|
| 673 | */ |
|
| 674 | public function testListAutogeneratedLocationAliasesPathCustomConfiguration( |
|
| 675 | $spiUrlAliases, |
|
| 676 | $prioritizedLanguageCodes, |
|
| 677 | $paths |
|
| 678 | ) { |
|
| 679 | $urlAliasService = $this->getRepository()->getURLAliasService(); |
|
| 680 | $configuration = [ |
|
| 681 | 'prioritizedLanguageList' => [], |
|
| 682 | 'showAllTranslations' => false, |
|
| 683 | ]; |
|
| 684 | $this->setConfiguration($urlAliasService, $configuration); |
|
| 685 | ||
| 686 | $urlAliasHandler = $this->getPersistenceMockHandler('Content\\UrlAlias\\Handler'); |
|
| 687 | $urlAliasHandler->expects( |
|
| 688 | $this->once() |
|
| 689 | )->method( |
|
| 690 | 'listURLAliasesForLocation' |
|
| 691 | )->with( |
|
| 692 | $this->equalTo(42), |
|
| 693 | $this->equalTo(false) |
|
| 694 | )->will( |
|
| 695 | $this->returnValue($spiUrlAliases) |
|
| 696 | ); |
|
| 697 | ||
| 698 | $location = $this->getLocationStub(); |
|
| 699 | $urlAliases = $urlAliasService->listLocationAliases( |
|
| 700 | $location, |
|
| 701 | false, |
|
| 702 | null, |
|
| 703 | false, |
|
| 704 | $prioritizedLanguageCodes |
|
| 705 | ); |
|
| 706 | ||
| 707 | self::assertEquals( |
|
| 708 | count($paths), |
|
| 709 | count($urlAliases) |
|
| 710 | ); |
|
| 711 | ||
| 712 | foreach ($urlAliases as $index => $urlAlias) { |
|
| 713 | $pathKeys = array_keys($paths); |
|
| 714 | self::assertEquals( |
|
| 715 | $paths[$pathKeys[$index]], |
|
| 716 | $urlAlias->path |
|
| 717 | ); |
|
| 718 | self::assertEquals( |
|
| 719 | [$pathKeys[$index]], |
|
| 720 | $urlAlias->languageCodes |
|
| 721 | ); |
|
| 722 | } |
|
| 723 | } |
|
| 724 | ||
| 725 | /** |
|
| 726 | * Test for the load() method. |
|