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