Code Duplication    Length = 69-69 lines in 2 locations

eZ/Publish/Core/Search/Legacy/Tests/Content/HandlerContentSortTest.php 1 location

@@ 435-503 (lines=69) @@
432
        );
433
    }
434
435
    public function testSortFieldText()
436
    {
437
        $locator = $this->getContentSearchHandler();
438
439
        $result = $locator->findContent(
440
            new Query(
441
                array(
442
                    'filter' => new Criterion\LogicalAnd(
443
                        array(
444
                            new Criterion\SectionId(array(1)),
445
                            new Criterion\ContentTypeIdentifier(array('article')),
446
                        )
447
                    ),
448
                    'offset' => 0,
449
                    'limit' => null,
450
                    'sortClauses' => array(
451
                        new SortClause\Field('article', 'title', Query::SORT_ASC, 'eng-US'),
452
                    ),
453
                )
454
            )
455
        );
456
457
        // There are several identical titles, need to take care about this
458
        $idMapSet = array(
459
            'aenean malesuada ligula' => array(83),
460
            'aliquam pulvinar suscipit tellus' => array(102),
461
            'asynchronous publishing' => array(148, 215),
462
            'canonical links' => array(147, 216),
463
            'class aptent taciti' => array(88),
464
            'class aptent taciti sociosqu' => array(82),
465
            'duis auctor vehicula erat' => array(89),
466
            'etiam posuere sodales arcu' => array(78),
467
            'etiam sodales mauris' => array(87),
468
            'ez publish enterprise' => array(151),
469
            'fastcgi' => array(144, 218),
470
            'fusce sagittis sagittis' => array(77),
471
            'fusce sagittis sagittis urna' => array(81),
472
            'get involved' => array(107),
473
            'how to develop with ez publish' => array(127, 211),
474
            'how to manage ez publish' => array(118, 202),
475
            'how to use ez publish' => array(108, 193),
476
            'improved block editing' => array(136),
477
            'improved front-end editing' => array(139),
478
            'improved user registration workflow' => array(132),
479
            'in hac habitasse platea' => array(79),
480
            'lots of websites, one ez publish installation' => array(130),
481
            'rest api interface' => array(150, 214),
482
            'separate content & design in ez publish' => array(191),
483
            'support for red hat enterprise' => array(145, 217),
484
            'tutorials for' => array(106),
485
        );
486
        $contentIds = array_map(
487
            function ($hit) {
488
                return $hit->valueObject->id;
489
            },
490
            $result->searchHits
491
        );
492
        $index = 0;
493
494
        foreach ($idMapSet as $idSet) {
495
            $contentIdsSubset = array_slice($contentIds, $index, $count = count($idSet));
496
            $index += $count;
497
            sort($contentIdsSubset);
498
            $this->assertEquals(
499
                $idSet,
500
                $contentIdsSubset
501
            );
502
        }
503
    }
504
505
    public function testSortFieldNumeric()
506
    {

eZ/Publish/Core/Search/Legacy/Tests/Content/HandlerLocationSortTest.php 1 location

@@ 590-658 (lines=69) @@
587
        }
588
    }
589
590
    public function testSortFieldText()
591
    {
592
        $handler = $this->getContentSearchHandler();
593
594
        $result = $handler->findLocations(
595
            new LocationQuery(
596
                array(
597
                    'filter' => new Criterion\LogicalAnd(
598
                        array(
599
                            new Criterion\SectionId(array(1)),
600
                            new Criterion\ContentTypeIdentifier(array('article')),
601
                        )
602
                    ),
603
                    'offset' => 0,
604
                    'limit' => null,
605
                    'sortClauses' => array(
606
                        new SortClause\Field('article', 'title', LocationQuery::SORT_ASC, 'eng-US'),
607
                    ),
608
                )
609
            )
610
        );
611
612
        // There are several identical titles, need to take care about this
613
        $idMapSet = array(
614
            'aenean malesuada ligula' => array(85),
615
            'aliquam pulvinar suscipit tellus' => array(104),
616
            'asynchronous publishing' => array(150, 217),
617
            'canonical links' => array(149, 218),
618
            'class aptent taciti' => array(90),
619
            'class aptent taciti sociosqu' => array(84),
620
            'duis auctor vehicula erat' => array(91),
621
            'etiam posuere sodales arcu' => array(80),
622
            'etiam sodales mauris' => array(89),
623
            'ez publish enterprise' => array(153),
624
            'fastcgi' => array(146, 220),
625
            'fusce sagittis sagittis' => array(79),
626
            'fusce sagittis sagittis urna' => array(83),
627
            'get involved' => array(109),
628
            'how to develop with ez publish' => array(129, 213),
629
            'how to manage ez publish' => array(120, 204),
630
            'how to use ez publish' => array(110, 195),
631
            'improved block editing' => array(138),
632
            'improved front-end editing' => array(141),
633
            'improved user registration workflow' => array(134),
634
            'in hac habitasse platea' => array(81),
635
            'lots of websites, one ez publish installation' => array(132),
636
            'rest api interface' => array(152, 216),
637
            'separate content & design in ez publish' => array(193),
638
            'support for red hat enterprise' => array(147, 219),
639
            'tutorials for' => array(108),
640
        );
641
        $locationIds = array_map(
642
            function ($hit) {
643
                return $hit->valueObject->id;
644
            },
645
            $result->searchHits
646
        );
647
        $index = 0;
648
649
        foreach ($idMapSet as $idSet) {
650
            $locationIdsSubset = array_slice($locationIds, $index, $count = count($idSet));
651
            $index += $count;
652
            sort($locationIdsSubset);
653
            $this->assertEquals(
654
                $idSet,
655
                $locationIdsSubset
656
            );
657
        }
658
    }
659
660
    public function testSortFieldNumeric()
661
    {