Code Duplication    Length = 31-32 lines in 9 locations

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

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