| @@ 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 | [ |
|
| 440 | 'filter' => new Criterion\LogicalAnd( |
|
| 441 | [ |
|
| 442 | new Criterion\SectionId([1]), |
|
| 443 | new Criterion\ContentTypeIdentifier(['article']), |
|
| 444 | ] |
|
| 445 | ), |
|
| 446 | 'offset' => 0, |
|
| 447 | 'limit' => null, |
|
| 448 | 'sortClauses' => [ |
|
| 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 = [ |
|
| 457 | 'aenean malesuada ligula' => [83], |
|
| 458 | 'aliquam pulvinar suscipit tellus' => [102], |
|
| 459 | 'asynchronous publishing' => [148, 215], |
|
| 460 | 'canonical links' => [147, 216], |
|
| 461 | 'class aptent taciti' => [88], |
|
| 462 | 'class aptent taciti sociosqu' => [82], |
|
| 463 | 'duis auctor vehicula erat' => [89], |
|
| 464 | 'etiam posuere sodales arcu' => [78], |
|
| 465 | 'etiam sodales mauris' => [87], |
|
| 466 | 'ez publish enterprise' => [151], |
|
| 467 | 'fastcgi' => [144, 218], |
|
| 468 | 'fusce sagittis sagittis' => [77], |
|
| 469 | 'fusce sagittis sagittis urna' => [81], |
|
| 470 | 'get involved' => [107], |
|
| 471 | 'how to develop with ez publish' => [127, 211], |
|
| 472 | 'how to manage ez publish' => [118, 202], |
|
| 473 | 'how to use ez publish' => [108, 193], |
|
| 474 | 'improved block editing' => [136], |
|
| 475 | 'improved front-end editing' => [139], |
|
| 476 | 'improved user registration workflow' => [132], |
|
| 477 | 'in hac habitasse platea' => [79], |
|
| 478 | 'lots of websites, one ez publish installation' => [130], |
|
| 479 | 'rest api interface' => [150, 214], |
|
| 480 | 'separate content & design in ez publish' => [191], |
|
| 481 | 'support for red hat enterprise' => [145, 217], |
|
| 482 | 'tutorials for' => [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 | { |
|
| @@ 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 | [ |
|
| 594 | 'filter' => new Criterion\LogicalAnd( |
|
| 595 | [ |
|
| 596 | new Criterion\SectionId([1]), |
|
| 597 | new Criterion\ContentTypeIdentifier(['article']), |
|
| 598 | ] |
|
| 599 | ), |
|
| 600 | 'offset' => 0, |
|
| 601 | 'limit' => null, |
|
| 602 | 'sortClauses' => [ |
|
| 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 = [ |
|
| 611 | 'aenean malesuada ligula' => [85], |
|
| 612 | 'aliquam pulvinar suscipit tellus' => [104], |
|
| 613 | 'asynchronous publishing' => [150, 217], |
|
| 614 | 'canonical links' => [149, 218], |
|
| 615 | 'class aptent taciti' => [90], |
|
| 616 | 'class aptent taciti sociosqu' => [84], |
|
| 617 | 'duis auctor vehicula erat' => [91], |
|
| 618 | 'etiam posuere sodales arcu' => [80], |
|
| 619 | 'etiam sodales mauris' => [89], |
|
| 620 | 'ez publish enterprise' => [153], |
|
| 621 | 'fastcgi' => [146, 220], |
|
| 622 | 'fusce sagittis sagittis' => [79], |
|
| 623 | 'fusce sagittis sagittis urna' => [83], |
|
| 624 | 'get involved' => [109], |
|
| 625 | 'how to develop with ez publish' => [129, 213], |
|
| 626 | 'how to manage ez publish' => [120, 204], |
|
| 627 | 'how to use ez publish' => [110, 195], |
|
| 628 | 'improved block editing' => [138], |
|
| 629 | 'improved front-end editing' => [141], |
|
| 630 | 'improved user registration workflow' => [134], |
|
| 631 | 'in hac habitasse platea' => [81], |
|
| 632 | 'lots of websites, one ez publish installation' => [132], |
|
| 633 | 'rest api interface' => [152, 216], |
|
| 634 | 'separate content & design in ez publish' => [193], |
|
| 635 | 'support for red hat enterprise' => [147, 219], |
|
| 636 | 'tutorials for' => [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 | { |
|