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