Code Duplication    Length = 69-69 lines in 2 locations

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

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

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

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