Code Duplication    Length = 69-69 lines in 2 locations

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

@@ 374-442 (lines=69) @@
371
        );
372
    }
373
374
    public function testSortFieldText()
375
    {
376
        $locator = $this->getContentSearchHandler();
377
378
        $result = $locator->findContent(
379
            new Query(
380
                array(
381
                    'filter' => new Criterion\LogicalAnd(
382
                        array(
383
                            new Criterion\SectionId(array(1)),
384
                            new Criterion\ContentTypeIdentifier(array('article')),
385
                        )
386
                    ),
387
                    'offset' => 0,
388
                    'limit' => null,
389
                    'sortClauses' => array(
390
                        new SortClause\Field('article', 'title', Query::SORT_ASC, 'eng-US'),
391
                    ),
392
                )
393
            )
394
        );
395
396
        // There are several identical titles, need to take care about this
397
        $idMapSet = array(
398
            'aenean malesuada ligula' => array(83),
399
            'aliquam pulvinar suscipit tellus' => array(102),
400
            'asynchronous publishing' => array(148, 215),
401
            'canonical links' => array(147, 216),
402
            'class aptent taciti' => array(88),
403
            'class aptent taciti sociosqu' => array(82),
404
            'duis auctor vehicula erat' => array(89),
405
            'etiam posuere sodales arcu' => array(78),
406
            'etiam sodales mauris' => array(87),
407
            'ez publish enterprise' => array(151),
408
            'fastcgi' => array(144, 218),
409
            'fusce sagittis sagittis' => array(77),
410
            'fusce sagittis sagittis urna' => array(81),
411
            'get involved' => array(107),
412
            'how to develop with ez publish' => array(127, 211),
413
            'how to manage ez publish' => array(118, 202),
414
            'how to use ez publish' => array(108, 193),
415
            'improved block editing' => array(136),
416
            'improved front-end editing' => array(139),
417
            'improved user registration workflow' => array(132),
418
            'in hac habitasse platea' => array(79),
419
            'lots of websites, one ez publish installation' => array(130),
420
            'rest api interface' => array(150, 214),
421
            'separate content & design in ez publish' => array(191),
422
            'support for red hat enterprise' => array(145, 217),
423
            'tutorials for' => array(106),
424
        );
425
        $contentIds = array_map(
426
            function ($hit) {
427
                return $hit->valueObject->id;
428
            },
429
            $result->searchHits
430
        );
431
        $index = 0;
432
433
        foreach ($idMapSet as $idSet) {
434
            $contentIdsSubset = array_slice($contentIds, $index, $count = count($idSet));
435
            $index += $count;
436
            sort($contentIdsSubset);
437
            $this->assertEquals(
438
                $idSet,
439
                $contentIdsSubset
440
            );
441
        }
442
    }
443
444
    public function testSortFieldNumeric()
445
    {

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

@@ 510-578 (lines=69) @@
507
        }
508
    }
509
510
    public function testSortFieldText()
511
    {
512
        $handler = $this->getContentSearchHandler();
513
514
        $result = $handler->findLocations(
515
            new LocationQuery(
516
                array(
517
                    'filter' => new Criterion\LogicalAnd(
518
                        array(
519
                            new Criterion\SectionId(array(1)),
520
                            new Criterion\ContentTypeIdentifier(array('article')),
521
                        )
522
                    ),
523
                    'offset' => 0,
524
                    'limit' => null,
525
                    'sortClauses' => array(
526
                        new SortClause\Field('article', 'title', LocationQuery::SORT_ASC, 'eng-US'),
527
                    ),
528
                )
529
            )
530
        );
531
532
        // There are several identical titles, need to take care about this
533
        $idMapSet = array(
534
            'aenean malesuada ligula' => array(85),
535
            'aliquam pulvinar suscipit tellus' => array(104),
536
            'asynchronous publishing' => array(150, 217),
537
            'canonical links' => array(149, 218),
538
            'class aptent taciti' => array(90),
539
            'class aptent taciti sociosqu' => array(84),
540
            'duis auctor vehicula erat' => array(91),
541
            'etiam posuere sodales arcu' => array(80),
542
            'etiam sodales mauris' => array(89),
543
            'ez publish enterprise' => array(153),
544
            'fastcgi' => array(146, 220),
545
            'fusce sagittis sagittis' => array(79),
546
            'fusce sagittis sagittis urna' => array(83),
547
            'get involved' => array(109),
548
            'how to develop with ez publish' => array(129, 213),
549
            'how to manage ez publish' => array(120, 204),
550
            'how to use ez publish' => array(110, 195),
551
            'improved block editing' => array(138),
552
            'improved front-end editing' => array(141),
553
            'improved user registration workflow' => array(134),
554
            'in hac habitasse platea' => array(81),
555
            'lots of websites, one ez publish installation' => array(132),
556
            'rest api interface' => array(152, 216),
557
            'separate content & design in ez publish' => array(193),
558
            'support for red hat enterprise' => array(147, 219),
559
            'tutorials for' => array(108),
560
        );
561
        $locationIds = array_map(
562
            function ($hit) {
563
                return $hit->valueObject->id;
564
            },
565
            $result->searchHits
566
        );
567
        $index = 0;
568
569
        foreach ($idMapSet as $idSet) {
570
            $locationIdsSubset = array_slice($locationIds, $index, $count = count($idSet));
571
            $index += $count;
572
            sort($locationIdsSubset);
573
            $this->assertEquals(
574
                $idSet,
575
                $locationIdsSubset
576
            );
577
        }
578
    }
579
580
    public function testSortFieldNumeric()
581
    {