public function testSorting()
 {
     $this->assertNull($this->searchOptions->getSortField());
     $this->assertNull($this->searchOptions->getSortOrder());
     $sortField = SortField::DISPLAY_NAME();
     $this->searchOptions = $this->searchOptions->withSorting($sortField);
     $this->assertEquals($sortField, $this->searchOptions->getSortField());
     $this->assertEquals(SortOrder::ASC(), $this->searchOptions->getSortOrder());
     $sortOrder = SortOrder::DESC();
     $this->searchOptions = $this->searchOptions->withSorting($sortField, $sortOrder);
     $this->assertEquals($sortField, $this->searchOptions->getSortField());
     $this->assertEquals($sortOrder, $this->searchOptions->getSortOrder());
 }
 /**
  * @param SearchOptions $searchOptions
  * @return array
  */
 public static function build(SearchOptions $searchOptions)
 {
     $queryParameters = [];
     if (!is_null($searchOptions->getPage())) {
         $queryParameters[self::PAGE] = $searchOptions->getPage()->toNative();
     }
     if (!is_null($searchOptions->getLimit())) {
         $queryParameters[self::LIMIT] = $searchOptions->getLimit()->toNative();
     }
     if (!is_null($searchOptions->getQuery())) {
         $queryParameters[self::QUERY] = $searchOptions->getQuery()->toNative();
     }
     if (!is_null($searchOptions->getSortField())) {
         $queryParameters[self::SORTING] = $searchOptions->getSortField()->toNative() . '_' . $searchOptions->getSortOrder()->toNative();
     }
     if ($searchOptions->getDetails()) {
         $queryParameters[self::DETAILED] = true;
     }
     return $queryParameters;
 }