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