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

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