Code Duplication    Length = 31-32 lines in 9 locations

eZ/Publish/Core/Persistence/Legacy/Tests/Content/UrlAlias/UrlAliasHandlerTest.php 9 locations

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