@@ 349-379 (lines=31) @@ | ||
346 | * @depends testLookup |
|
347 | * @group location |
|
348 | */ |
|
349 | public function testLookupLocationUrlAlias( |
|
350 | $url, |
|
351 | array $pathData, |
|
352 | array $languageCodes, |
|
353 | $alwaysAvailable, |
|
354 | $locationId, |
|
355 | $id |
|
356 | ) { |
|
357 | $handler = $this->getHandler(); |
|
358 | $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php'); |
|
359 | ||
360 | $urlAlias = $handler->lookup($url); |
|
361 | ||
362 | self::assertInstanceOf(UrlAlias::class, $urlAlias); |
|
363 | self::assertEquals( |
|
364 | new UrlAlias( |
|
365 | [ |
|
366 | 'id' => $id, |
|
367 | 'type' => UrlAlias::LOCATION, |
|
368 | 'destination' => $locationId, |
|
369 | 'languageCodes' => $languageCodes, |
|
370 | 'pathData' => $pathData, |
|
371 | 'alwaysAvailable' => $alwaysAvailable, |
|
372 | 'isHistory' => false, |
|
373 | 'isCustom' => false, |
|
374 | 'forward' => false, |
|
375 | ] |
|
376 | ), |
|
377 | $urlAlias |
|
378 | ); |
|
379 | } |
|
380 | ||
381 | /** |
|
382 | * Testing that looking up case incorrect URL results in redirection to case correct path. |
|
@@ 400-430 (lines=31) @@ | ||
397 | * |
|
398 | * @todo refactor, only forward pertinent |
|
399 | */ |
|
400 | public function testLookupLocationCaseCorrection( |
|
401 | $url, |
|
402 | array $pathData, |
|
403 | array $languageCodes, |
|
404 | $alwaysAvailable, |
|
405 | $locationId, |
|
406 | $id |
|
407 | ) { |
|
408 | $handler = $this->getHandler(); |
|
409 | $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php'); |
|
410 | ||
411 | $urlAlias = $handler->lookup(strtoupper($url)); |
|
412 | ||
413 | self::assertInstanceOf(UrlAlias::class, $urlAlias); |
|
414 | self::assertEquals( |
|
415 | new UrlAlias( |
|
416 | [ |
|
417 | 'id' => $id, |
|
418 | 'type' => UrlAlias::LOCATION, |
|
419 | 'destination' => $locationId, |
|
420 | 'languageCodes' => $languageCodes, |
|
421 | 'pathData' => $pathData, |
|
422 | 'alwaysAvailable' => $alwaysAvailable, |
|
423 | 'isHistory' => false, |
|
424 | 'isCustom' => false, |
|
425 | 'forward' => false, |
|
426 | ] |
|
427 | ), |
|
428 | $urlAlias |
|
429 | ); |
|
430 | } |
|
431 | ||
432 | public function providerForTestLookupLocationMultipleLanguages() |
|
433 | { |
|
@@ 527-557 (lines=31) @@ | ||
524 | * @group multiple-languages |
|
525 | * @group location |
|
526 | */ |
|
527 | public function testLookupLocationMultipleLanguages( |
|
528 | $url, |
|
529 | array $pathData, |
|
530 | array $languageCodes, |
|
531 | $alwaysAvailable, |
|
532 | $locationId, |
|
533 | $id |
|
534 | ) { |
|
535 | $handler = $this->getHandler(); |
|
536 | $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_multilang.php'); |
|
537 | ||
538 | $urlAlias = $handler->lookup($url); |
|
539 | ||
540 | self::assertInstanceOf(UrlAlias::class, $urlAlias); |
|
541 | self::assertEquals( |
|
542 | new UrlAlias( |
|
543 | [ |
|
544 | 'id' => $id, |
|
545 | 'type' => UrlAlias::LOCATION, |
|
546 | 'destination' => $locationId, |
|
547 | 'languageCodes' => $languageCodes, |
|
548 | 'pathData' => $pathData, |
|
549 | 'alwaysAvailable' => $alwaysAvailable, |
|
550 | 'isHistory' => false, |
|
551 | 'isCustom' => false, |
|
552 | 'forward' => false, |
|
553 | ] |
|
554 | ), |
|
555 | $urlAlias |
|
556 | ); |
|
557 | } |
|
558 | ||
559 | /** |
|
560 | * Test for the lookup() method. |
|
@@ 709-739 (lines=31) @@ | ||
706 | * @group location |
|
707 | * @group custom |
|
708 | */ |
|
709 | public function testLookupCustomLocationUrlAlias( |
|
710 | $url, |
|
711 | array $pathData, |
|
712 | array $languageCodes, |
|
713 | $forward, |
|
714 | $alwaysAvailable, |
|
715 | $destination, |
|
716 | $id |
|
717 | ) { |
|
718 | $handler = $this->getHandler(); |
|
719 | $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_custom.php'); |
|
720 | ||
721 | $urlAlias = $handler->lookup($url); |
|
722 | self::assertInstanceOf(UrlAlias::class, $urlAlias); |
|
723 | self::assertEquals( |
|
724 | new UrlAlias( |
|
725 | [ |
|
726 | 'id' => $id, |
|
727 | 'type' => UrlAlias::LOCATION, |
|
728 | 'destination' => $destination, |
|
729 | 'languageCodes' => $languageCodes, |
|
730 | 'pathData' => $pathData, |
|
731 | 'alwaysAvailable' => $alwaysAvailable, |
|
732 | 'isHistory' => false, |
|
733 | 'isCustom' => true, |
|
734 | 'forward' => $forward, |
|
735 | ] |
|
736 | ), |
|
737 | $urlAlias |
|
738 | ); |
|
739 | } |
|
740 | ||
741 | /** |
|
742 | * Test for the lookup() method. |
|
@@ 752-783 (lines=32) @@ | ||
749 | * @group location |
|
750 | * @group custom |
|
751 | */ |
|
752 | public function testLookupCustomLocationUrlAliasCaseCorrection( |
|
753 | $url, |
|
754 | array $pathData, |
|
755 | array $languageCodes, |
|
756 | $forward, |
|
757 | $alwaysAvailable, |
|
758 | $destination, |
|
759 | $id |
|
760 | ) { |
|
761 | $handler = $this->getHandler(); |
|
762 | $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_custom.php'); |
|
763 | ||
764 | $urlAlias = $handler->lookup(strtoupper($url)); |
|
765 | ||
766 | self::assertInstanceOf(UrlAlias::class, $urlAlias); |
|
767 | self::assertEquals( |
|
768 | new UrlAlias( |
|
769 | [ |
|
770 | 'id' => $id, |
|
771 | 'type' => UrlAlias::LOCATION, |
|
772 | 'destination' => $destination, |
|
773 | 'languageCodes' => $languageCodes, |
|
774 | 'pathData' => $pathData, |
|
775 | 'alwaysAvailable' => $alwaysAvailable, |
|
776 | 'isHistory' => false, |
|
777 | 'isCustom' => true, |
|
778 | 'forward' => $forward, |
|
779 | ] |
|
780 | ), |
|
781 | $urlAlias |
|
782 | ); |
|
783 | } |
|
784 | ||
785 | public function providerForTestLookupVirtualUrlAlias() |
|
786 | { |
|
@@ 879-910 (lines=32) @@ | ||
876 | * @depends testLookup |
|
877 | * @group resource |
|
878 | */ |
|
879 | public function testLookupResourceUrlAlias( |
|
880 | $url, |
|
881 | $pathData, |
|
882 | array $languageCodes, |
|
883 | $forward, |
|
884 | $alwaysAvailable, |
|
885 | $destination, |
|
886 | $id |
|
887 | ) { |
|
888 | $handler = $this->getHandler(); |
|
889 | $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
|
890 | ||
891 | $urlAlias = $handler->lookup($url); |
|
892 | ||
893 | self::assertInstanceOf(UrlAlias::class, $urlAlias); |
|
894 | self::assertEquals( |
|
895 | new UrlAlias( |
|
896 | [ |
|
897 | 'id' => $id, |
|
898 | 'type' => UrlAlias::RESOURCE, |
|
899 | 'destination' => $destination, |
|
900 | 'languageCodes' => $languageCodes, |
|
901 | 'pathData' => $pathData, |
|
902 | 'alwaysAvailable' => $alwaysAvailable, |
|
903 | 'isHistory' => false, |
|
904 | 'isCustom' => true, |
|
905 | 'forward' => $forward, |
|
906 | ] |
|
907 | ), |
|
908 | $urlAlias |
|
909 | ); |
|
910 | } |
|
911 | ||
912 | /** |
|
913 | * Test for the lookup() method. |
|
@@ 922-953 (lines=32) @@ | ||
919 | * @depends testLookup |
|
920 | * @group resource |
|
921 | */ |
|
922 | public function testLookupResourceUrlAliasCaseInsensitive( |
|
923 | $url, |
|
924 | $pathData, |
|
925 | array $languageCodes, |
|
926 | $forward, |
|
927 | $alwaysAvailable, |
|
928 | $destination, |
|
929 | $id |
|
930 | ) { |
|
931 | $handler = $this->getHandler(); |
|
932 | $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
|
933 | ||
934 | $urlAlias = $handler->lookup(strtoupper($url)); |
|
935 | ||
936 | self::assertInstanceOf(UrlAlias::class, $urlAlias); |
|
937 | self::assertEquals( |
|
938 | new UrlAlias( |
|
939 | [ |
|
940 | 'id' => $id, |
|
941 | 'type' => UrlAlias::RESOURCE, |
|
942 | 'destination' => $destination, |
|
943 | 'languageCodes' => $languageCodes, |
|
944 | 'pathData' => $pathData, |
|
945 | 'alwaysAvailable' => $alwaysAvailable, |
|
946 | 'isHistory' => false, |
|
947 | 'isCustom' => true, |
|
948 | 'forward' => $forward, |
|
949 | ] |
|
950 | ), |
|
951 | $urlAlias |
|
952 | ); |
|
953 | } |
|
954 | ||
955 | /** |
|
956 | * Test for the lookup() method with uppercase utf8 characters. |
|
@@ 2998-3028 (lines=31) @@ | ||
2995 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias |
|
2996 | * @dataProvider providerForTestLookupLocationMultipleLanguages |
|
2997 | */ |
|
2998 | public function testLoadAutogeneratedUrlAlias( |
|
2999 | $url, |
|
3000 | array $pathData, |
|
3001 | array $languageCodes, |
|
3002 | $alwaysAvailable, |
|
3003 | $locationId, |
|
3004 | $id |
|
3005 | ) { |
|
3006 | $handler = $this->getHandler(); |
|
3007 | $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_multilang.php'); |
|
3008 | ||
3009 | $urlAlias = $handler->loadUrlAlias($id); |
|
3010 | ||
3011 | self::assertInstanceOf(UrlAlias::class, $urlAlias); |
|
3012 | self::assertEquals( |
|
3013 | new UrlAlias( |
|
3014 | [ |
|
3015 | 'id' => $id, |
|
3016 | 'type' => UrlAlias::LOCATION, |
|
3017 | 'destination' => $locationId, |
|
3018 | 'languageCodes' => $languageCodes, |
|
3019 | 'pathData' => $pathData, |
|
3020 | 'alwaysAvailable' => $alwaysAvailable, |
|
3021 | 'isHistory' => false, |
|
3022 | 'isCustom' => false, |
|
3023 | 'forward' => false, |
|
3024 | ] |
|
3025 | ), |
|
3026 | $urlAlias |
|
3027 | ); |
|
3028 | } |
|
3029 | ||
3030 | /** |
|
3031 | * Test for the loadUrlAlias() method. |
|
@@ 3036-3067 (lines=32) @@ | ||
3033 | * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias |
|
3034 | * @dataProvider providerForTestLookupResourceUrlAlias |
|
3035 | */ |
|
3036 | public function testLoadResourceUrlAlias( |
|
3037 | $url, |
|
3038 | $pathData, |
|
3039 | array $languageCodes, |
|
3040 | $forward, |
|
3041 | $alwaysAvailable, |
|
3042 | $destination, |
|
3043 | $id |
|
3044 | ) { |
|
3045 | $handler = $this->getHandler(); |
|
3046 | $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php'); |
|
3047 | ||
3048 | $urlAlias = $handler->loadUrlAlias($id); |
|
3049 | ||
3050 | self::assertInstanceOf(UrlAlias::class, $urlAlias); |
|
3051 | self::assertEquals( |
|
3052 | new UrlAlias( |
|
3053 | [ |
|
3054 | 'id' => $id, |
|
3055 | 'type' => UrlAlias::RESOURCE, |
|
3056 | 'destination' => $destination, |
|
3057 | 'languageCodes' => $languageCodes, |
|
3058 | 'pathData' => $pathData, |
|
3059 | 'alwaysAvailable' => $alwaysAvailable, |
|
3060 | 'isHistory' => false, |
|
3061 | 'isCustom' => true, |
|
3062 | 'forward' => $forward, |
|
3063 | ] |
|
3064 | ), |
|
3065 | $urlAlias |
|
3066 | ); |
|
3067 | } |
|
3068 | ||
3069 | /** |
|
3070 | * Test for the loadUrlAlias() method. |