Code Duplication    Length = 31-32 lines in 9 locations

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

@@ 348-378 (lines=31) @@
345
     * @depends testLookup
346
     * @group location
347
     */
348
    public function testLookupLocationUrlAlias(
349
        $url,
350
        array $pathData,
351
        array $languageCodes,
352
        $alwaysAvailable,
353
        $locationId,
354
        $id
355
    ) {
356
        $handler = $this->getHandler();
357
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php');
358
359
        $urlAlias = $handler->lookup($url);
360
361
        self::assertInstanceOf(UrlAlias::class, $urlAlias);
362
        self::assertEquals(
363
            new UrlAlias(
364
                array(
365
                    'id' => $id,
366
                    'type' => UrlAlias::LOCATION,
367
                    'destination' => $locationId,
368
                    'languageCodes' => $languageCodes,
369
                    'pathData' => $pathData,
370
                    'alwaysAvailable' => $alwaysAvailable,
371
                    'isHistory' => false,
372
                    'isCustom' => false,
373
                    'forward' => false,
374
                )
375
            ),
376
            $urlAlias
377
        );
378
    }
379
380
    /**
381
     * Testing that looking up case incorrect URL results in redirection to case correct path.
@@ 399-429 (lines=31) @@
396
     *
397
     * @todo refactor, only forward pertinent
398
     */
399
    public function testLookupLocationCaseCorrection(
400
        $url,
401
        array $pathData,
402
        array $languageCodes,
403
        $alwaysAvailable,
404
        $locationId,
405
        $id
406
    ) {
407
        $handler = $this->getHandler();
408
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location.php');
409
410
        $urlAlias = $handler->lookup(strtoupper($url));
411
412
        self::assertInstanceOf(UrlAlias::class, $urlAlias);
413
        self::assertEquals(
414
            new UrlAlias(
415
                array(
416
                    'id' => $id,
417
                    'type' => UrlAlias::LOCATION,
418
                    'destination' => $locationId,
419
                    'languageCodes' => $languageCodes,
420
                    'pathData' => $pathData,
421
                    'alwaysAvailable' => $alwaysAvailable,
422
                    'isHistory' => false,
423
                    'isCustom' => false,
424
                    'forward' => false,
425
                )
426
            ),
427
            $urlAlias
428
        );
429
    }
430
431
    public function providerForTestLookupLocationMultipleLanguages()
432
    {
@@ 526-556 (lines=31) @@
523
     * @group multiple-languages
524
     * @group location
525
     */
526
    public function testLookupLocationMultipleLanguages(
527
        $url,
528
        array $pathData,
529
        array $languageCodes,
530
        $alwaysAvailable,
531
        $locationId,
532
        $id
533
    ) {
534
        $handler = $this->getHandler();
535
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_multilang.php');
536
537
        $urlAlias = $handler->lookup($url);
538
539
        self::assertInstanceOf(UrlAlias::class, $urlAlias);
540
        self::assertEquals(
541
            new UrlAlias(
542
                array(
543
                    'id' => $id,
544
                    'type' => UrlAlias::LOCATION,
545
                    'destination' => $locationId,
546
                    'languageCodes' => $languageCodes,
547
                    'pathData' => $pathData,
548
                    'alwaysAvailable' => $alwaysAvailable,
549
                    'isHistory' => false,
550
                    'isCustom' => false,
551
                    'forward' => false,
552
                )
553
            ),
554
            $urlAlias
555
        );
556
    }
557
558
    /**
559
     * Test for the lookup() method.
@@ 708-738 (lines=31) @@
705
     * @group location
706
     * @group custom
707
     */
708
    public function testLookupCustomLocationUrlAlias(
709
        $url,
710
        array $pathData,
711
        array $languageCodes,
712
        $forward,
713
        $alwaysAvailable,
714
        $destination,
715
        $id
716
    ) {
717
        $handler = $this->getHandler();
718
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_custom.php');
719
720
        $urlAlias = $handler->lookup($url);
721
        self::assertInstanceOf(UrlAlias::class, $urlAlias);
722
        self::assertEquals(
723
            new UrlAlias(
724
                array(
725
                    'id' => $id,
726
                    'type' => UrlAlias::LOCATION,
727
                    'destination' => $destination,
728
                    'languageCodes' => $languageCodes,
729
                    'pathData' => $pathData,
730
                    'alwaysAvailable' => $alwaysAvailable,
731
                    'isHistory' => false,
732
                    'isCustom' => true,
733
                    'forward' => $forward,
734
                )
735
            ),
736
            $urlAlias
737
        );
738
    }
739
740
    /**
741
     * Test for the lookup() method.
@@ 751-782 (lines=32) @@
748
     * @group location
749
     * @group custom
750
     */
751
    public function testLookupCustomLocationUrlAliasCaseCorrection(
752
        $url,
753
        array $pathData,
754
        array $languageCodes,
755
        $forward,
756
        $alwaysAvailable,
757
        $destination,
758
        $id
759
    ) {
760
        $handler = $this->getHandler();
761
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_custom.php');
762
763
        $urlAlias = $handler->lookup(strtoupper($url));
764
765
        self::assertInstanceOf(UrlAlias::class, $urlAlias);
766
        self::assertEquals(
767
            new UrlAlias(
768
                array(
769
                    'id' => $id,
770
                    'type' => UrlAlias::LOCATION,
771
                    'destination' => $destination,
772
                    'languageCodes' => $languageCodes,
773
                    'pathData' => $pathData,
774
                    'alwaysAvailable' => $alwaysAvailable,
775
                    'isHistory' => false,
776
                    'isCustom' => true,
777
                    'forward' => $forward,
778
                )
779
            ),
780
            $urlAlias
781
        );
782
    }
783
784
    public function providerForTestLookupVirtualUrlAlias()
785
    {
@@ 878-909 (lines=32) @@
875
     * @depends testLookup
876
     * @group resource
877
     */
878
    public function testLookupResourceUrlAlias(
879
        $url,
880
        $pathData,
881
        array $languageCodes,
882
        $forward,
883
        $alwaysAvailable,
884
        $destination,
885
        $id
886
    ) {
887
        $handler = $this->getHandler();
888
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php');
889
890
        $urlAlias = $handler->lookup($url);
891
892
        self::assertInstanceOf(UrlAlias::class, $urlAlias);
893
        self::assertEquals(
894
            new UrlAlias(
895
                array(
896
                    'id' => $id,
897
                    'type' => UrlAlias::RESOURCE,
898
                    'destination' => $destination,
899
                    'languageCodes' => $languageCodes,
900
                    'pathData' => $pathData,
901
                    'alwaysAvailable' => $alwaysAvailable,
902
                    'isHistory' => false,
903
                    'isCustom' => true,
904
                    'forward' => $forward,
905
                )
906
            ),
907
            $urlAlias
908
        );
909
    }
910
911
    /**
912
     * Test for the lookup() method.
@@ 921-952 (lines=32) @@
918
     * @depends testLookup
919
     * @group resource
920
     */
921
    public function testLookupResourceUrlAliasCaseInsensitive(
922
        $url,
923
        $pathData,
924
        array $languageCodes,
925
        $forward,
926
        $alwaysAvailable,
927
        $destination,
928
        $id
929
    ) {
930
        $handler = $this->getHandler();
931
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php');
932
933
        $urlAlias = $handler->lookup(strtoupper($url));
934
935
        self::assertInstanceOf(UrlAlias::class, $urlAlias);
936
        self::assertEquals(
937
            new UrlAlias(
938
                array(
939
                    'id' => $id,
940
                    'type' => UrlAlias::RESOURCE,
941
                    'destination' => $destination,
942
                    'languageCodes' => $languageCodes,
943
                    'pathData' => $pathData,
944
                    'alwaysAvailable' => $alwaysAvailable,
945
                    'isHistory' => false,
946
                    'isCustom' => true,
947
                    'forward' => $forward,
948
                )
949
            ),
950
            $urlAlias
951
        );
952
    }
953
954
    /**
955
     * Test for the lookup() method with uppercase utf8 characters.
@@ 2940-2970 (lines=31) @@
2937
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias
2938
     * @dataProvider providerForTestLookupLocationMultipleLanguages
2939
     */
2940
    public function testLoadAutogeneratedUrlAlias(
2941
        $url,
2942
        array $pathData,
2943
        array $languageCodes,
2944
        $alwaysAvailable,
2945
        $locationId,
2946
        $id
2947
    ) {
2948
        $handler = $this->getHandler();
2949
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_location_multilang.php');
2950
2951
        $urlAlias = $handler->loadUrlAlias($id);
2952
2953
        self::assertInstanceOf(UrlAlias::class, $urlAlias);
2954
        self::assertEquals(
2955
            new UrlAlias(
2956
                array(
2957
                    'id' => $id,
2958
                    'type' => UrlAlias::LOCATION,
2959
                    'destination' => $locationId,
2960
                    'languageCodes' => $languageCodes,
2961
                    'pathData' => $pathData,
2962
                    'alwaysAvailable' => $alwaysAvailable,
2963
                    'isHistory' => false,
2964
                    'isCustom' => false,
2965
                    'forward' => false,
2966
                )
2967
            ),
2968
            $urlAlias
2969
        );
2970
    }
2971
2972
    /**
2973
     * Test for the loadUrlAlias() method.
@@ 2978-3009 (lines=32) @@
2975
     * @covers \eZ\Publish\Core\Persistence\Legacy\Content\UrlAlias\Handler::loadUrlAlias
2976
     * @dataProvider providerForTestLookupResourceUrlAlias
2977
     */
2978
    public function testLoadResourceUrlAlias(
2979
        $url,
2980
        $pathData,
2981
        array $languageCodes,
2982
        $forward,
2983
        $alwaysAvailable,
2984
        $destination,
2985
        $id
2986
    ) {
2987
        $handler = $this->getHandler();
2988
        $this->insertDatabaseFixture(__DIR__ . '/_fixtures/urlaliases_resource.php');
2989
2990
        $urlAlias = $handler->loadUrlAlias($id);
2991
2992
        self::assertInstanceOf(UrlAlias::class, $urlAlias);
2993
        self::assertEquals(
2994
            new UrlAlias(
2995
                array(
2996
                    'id' => $id,
2997
                    'type' => UrlAlias::RESOURCE,
2998
                    'destination' => $destination,
2999
                    'languageCodes' => $languageCodes,
3000
                    'pathData' => $pathData,
3001
                    'alwaysAvailable' => $alwaysAvailable,
3002
                    'isHistory' => false,
3003
                    'isCustom' => true,
3004
                    'forward' => $forward,
3005
                )
3006
            ),
3007
            $urlAlias
3008
        );
3009
    }
3010
3011
    /**
3012
     * Test for the loadUrlAlias() method.