| @@ 504-535 (lines=32) @@ | ||
| 501 | } |
|
| 502 | } |
|
| 503 | ||
| 504 | public function testSortFieldNumeric() |
|
| 505 | { |
|
| 506 | $locator = $this->getContentSearchHandler(); |
|
| 507 | ||
| 508 | $result = $locator->findContent( |
|
| 509 | new Query( |
|
| 510 | array( |
|
| 511 | 'filter' => new Criterion\LogicalAnd( |
|
| 512 | array( |
|
| 513 | new Criterion\SectionId(array(1)), |
|
| 514 | new Criterion\ContentTypeIdentifier('product'), |
|
| 515 | ) |
|
| 516 | ), |
|
| 517 | 'offset' => 0, |
|
| 518 | 'limit' => null, |
|
| 519 | 'sortClauses' => array( |
|
| 520 | new SortClause\Field('product', 'price', Query::SORT_ASC, 'eng-US'), |
|
| 521 | ), |
|
| 522 | ) |
|
| 523 | ) |
|
| 524 | ); |
|
| 525 | ||
| 526 | $this->assertEquals( |
|
| 527 | array(73, 71, 72, 69), |
|
| 528 | array_map( |
|
| 529 | function ($hit) { |
|
| 530 | return $hit->valueObject->id; |
|
| 531 | }, |
|
| 532 | $result->searchHits |
|
| 533 | ) |
|
| 534 | ); |
|
| 535 | } |
|
| 536 | } |
|
| 537 | ||
| @@ 658-689 (lines=32) @@ | ||
| 655 | } |
|
| 656 | } |
|
| 657 | ||
| 658 | public function testSortFieldNumeric() |
|
| 659 | { |
|
| 660 | $handler = $this->getContentSearchHandler(); |
|
| 661 | ||
| 662 | $result = $handler->findLocations( |
|
| 663 | new LocationQuery( |
|
| 664 | array( |
|
| 665 | 'filter' => new Criterion\LogicalAnd( |
|
| 666 | array( |
|
| 667 | new Criterion\SectionId(array(1)), |
|
| 668 | new Criterion\ContentTypeIdentifier('product'), |
|
| 669 | ) |
|
| 670 | ), |
|
| 671 | 'offset' => 0, |
|
| 672 | 'limit' => null, |
|
| 673 | 'sortClauses' => array( |
|
| 674 | new SortClause\Field('product', 'price', LocationQuery::SORT_ASC, 'eng-US'), |
|
| 675 | ), |
|
| 676 | ) |
|
| 677 | ) |
|
| 678 | ); |
|
| 679 | ||
| 680 | $this->assertEquals( |
|
| 681 | array(75, 73, 74, 71), |
|
| 682 | array_map( |
|
| 683 | function ($hit) { |
|
| 684 | return $hit->valueObject->id; |
|
| 685 | }, |
|
| 686 | $result->searchHits |
|
| 687 | ) |
|
| 688 | ); |
|
| 689 | } |
|
| 690 | ||
| 691 | public function testSortIsMainLocationAscending() |
|
| 692 | { |
|