@@ 427-495 (lines=69) @@ | ||
424 | ); |
|
425 | } |
|
426 | ||
427 | public function testSortFieldText() |
|
428 | { |
|
429 | $locator = $this->getContentSearchHandler(); |
|
430 | ||
431 | $result = $locator->findContent( |
|
432 | new Query( |
|
433 | array( |
|
434 | 'filter' => new Criterion\LogicalAnd( |
|
435 | array( |
|
436 | new Criterion\SectionId(array(1)), |
|
437 | new Criterion\ContentTypeIdentifier(array('article')), |
|
438 | ) |
|
439 | ), |
|
440 | 'offset' => 0, |
|
441 | 'limit' => null, |
|
442 | 'sortClauses' => array( |
|
443 | new SortClause\Field('article', 'title', Query::SORT_ASC, 'eng-US'), |
|
444 | ), |
|
445 | ) |
|
446 | ) |
|
447 | ); |
|
448 | ||
449 | // There are several identical titles, need to take care about this |
|
450 | $idMapSet = array( |
|
451 | 'aenean malesuada ligula' => array(83), |
|
452 | 'aliquam pulvinar suscipit tellus' => array(102), |
|
453 | 'asynchronous publishing' => array(148, 215), |
|
454 | 'canonical links' => array(147, 216), |
|
455 | 'class aptent taciti' => array(88), |
|
456 | 'class aptent taciti sociosqu' => array(82), |
|
457 | 'duis auctor vehicula erat' => array(89), |
|
458 | 'etiam posuere sodales arcu' => array(78), |
|
459 | 'etiam sodales mauris' => array(87), |
|
460 | 'ez publish enterprise' => array(151), |
|
461 | 'fastcgi' => array(144, 218), |
|
462 | 'fusce sagittis sagittis' => array(77), |
|
463 | 'fusce sagittis sagittis urna' => array(81), |
|
464 | 'get involved' => array(107), |
|
465 | 'how to develop with ez publish' => array(127, 211), |
|
466 | 'how to manage ez publish' => array(118, 202), |
|
467 | 'how to use ez publish' => array(108, 193), |
|
468 | 'improved block editing' => array(136), |
|
469 | 'improved front-end editing' => array(139), |
|
470 | 'improved user registration workflow' => array(132), |
|
471 | 'in hac habitasse platea' => array(79), |
|
472 | 'lots of websites, one ez publish installation' => array(130), |
|
473 | 'rest api interface' => array(150, 214), |
|
474 | 'separate content & design in ez publish' => array(191), |
|
475 | 'support for red hat enterprise' => array(145, 217), |
|
476 | 'tutorials for' => array(106), |
|
477 | ); |
|
478 | $contentIds = array_map( |
|
479 | function ($hit) { |
|
480 | return $hit->valueObject->id; |
|
481 | }, |
|
482 | $result->searchHits |
|
483 | ); |
|
484 | $index = 0; |
|
485 | ||
486 | foreach ($idMapSet as $idSet) { |
|
487 | $contentIdsSubset = array_slice($contentIds, $index, $count = count($idSet)); |
|
488 | $index += $count; |
|
489 | sort($contentIdsSubset); |
|
490 | $this->assertEquals( |
|
491 | $idSet, |
|
492 | $contentIdsSubset |
|
493 | ); |
|
494 | } |
|
495 | } |
|
496 | ||
497 | public function testSortFieldNumeric() |
|
498 | { |
@@ 581-649 (lines=69) @@ | ||
578 | } |
|
579 | } |
|
580 | ||
581 | public function testSortFieldText() |
|
582 | { |
|
583 | $handler = $this->getContentSearchHandler(); |
|
584 | ||
585 | $result = $handler->findLocations( |
|
586 | new LocationQuery( |
|
587 | array( |
|
588 | 'filter' => new Criterion\LogicalAnd( |
|
589 | array( |
|
590 | new Criterion\SectionId(array(1)), |
|
591 | new Criterion\ContentTypeIdentifier(array('article')), |
|
592 | ) |
|
593 | ), |
|
594 | 'offset' => 0, |
|
595 | 'limit' => null, |
|
596 | 'sortClauses' => array( |
|
597 | new SortClause\Field('article', 'title', LocationQuery::SORT_ASC, 'eng-US'), |
|
598 | ), |
|
599 | ) |
|
600 | ) |
|
601 | ); |
|
602 | ||
603 | // There are several identical titles, need to take care about this |
|
604 | $idMapSet = array( |
|
605 | 'aenean malesuada ligula' => array(85), |
|
606 | 'aliquam pulvinar suscipit tellus' => array(104), |
|
607 | 'asynchronous publishing' => array(150, 217), |
|
608 | 'canonical links' => array(149, 218), |
|
609 | 'class aptent taciti' => array(90), |
|
610 | 'class aptent taciti sociosqu' => array(84), |
|
611 | 'duis auctor vehicula erat' => array(91), |
|
612 | 'etiam posuere sodales arcu' => array(80), |
|
613 | 'etiam sodales mauris' => array(89), |
|
614 | 'ez publish enterprise' => array(153), |
|
615 | 'fastcgi' => array(146, 220), |
|
616 | 'fusce sagittis sagittis' => array(79), |
|
617 | 'fusce sagittis sagittis urna' => array(83), |
|
618 | 'get involved' => array(109), |
|
619 | 'how to develop with ez publish' => array(129, 213), |
|
620 | 'how to manage ez publish' => array(120, 204), |
|
621 | 'how to use ez publish' => array(110, 195), |
|
622 | 'improved block editing' => array(138), |
|
623 | 'improved front-end editing' => array(141), |
|
624 | 'improved user registration workflow' => array(134), |
|
625 | 'in hac habitasse platea' => array(81), |
|
626 | 'lots of websites, one ez publish installation' => array(132), |
|
627 | 'rest api interface' => array(152, 216), |
|
628 | 'separate content & design in ez publish' => array(193), |
|
629 | 'support for red hat enterprise' => array(147, 219), |
|
630 | 'tutorials for' => array(108), |
|
631 | ); |
|
632 | $locationIds = array_map( |
|
633 | function ($hit) { |
|
634 | return $hit->valueObject->id; |
|
635 | }, |
|
636 | $result->searchHits |
|
637 | ); |
|
638 | $index = 0; |
|
639 | ||
640 | foreach ($idMapSet as $idSet) { |
|
641 | $locationIdsSubset = array_slice($locationIds, $index, $count = count($idSet)); |
|
642 | $index += $count; |
|
643 | sort($locationIdsSubset); |
|
644 | $this->assertEquals( |
|
645 | $idSet, |
|
646 | $locationIdsSubset |
|
647 | ); |
|
648 | } |
|
649 | } |
|
650 | ||
651 | public function testSortFieldNumeric() |
|
652 | { |