diff --git a/src/Dto/Search/Query/Sort/CustomField.php b/src/Dto/Search/Query/Sort/CustomField.php new file mode 100644 index 0000000..7fcb072 --- /dev/null +++ b/src/Dto/Search/Query/Sort/CustomField.php @@ -0,0 +1,18 @@ +field; default: throw new InvalidArgumentException( 'Unsupported sort criteria: ' . get_class($criteria) diff --git a/test/Service/Search/Schema2xFieldMapperTest.php b/test/Service/Search/Schema2xFieldMapperTest.php index 7c8404d..c7615f5 100644 --- a/test/Service/Search/Schema2xFieldMapperTest.php +++ b/test/Service/Search/Schema2xFieldMapperTest.php @@ -22,6 +22,7 @@ use Atoolo\Search\Dto\Search\Query\Filter\RelativeDateRangeFilter; use Atoolo\Search\Dto\Search\Query\Filter\SiteFilter; use Atoolo\Search\Dto\Search\Query\Sort\Criteria; +use Atoolo\Search\Dto\Search\Query\Sort\CustomField; use Atoolo\Search\Dto\Search\Query\Sort\Date; use Atoolo\Search\Dto\Search\Query\Sort\Headline; use Atoolo\Search\Dto\Search\Query\Sort\Name; @@ -158,6 +159,15 @@ public function testGetSortField( ); } + public function testGetSortCustomField(): void + { + $criteria = new CustomField('custom_field'); + $this->assertEquals( + 'custom_field', + $this->mapper->getSortField($criteria) + ); + } + public function testUnsupportedSortField(): void { $this->expectException(InvalidArgumentException::class);