Code Duplication    Length = 69-69 lines in 2 locations

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

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

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

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