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