Code Duplication    Length = 69-69 lines in 2 locations

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

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

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

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