You are here

public function IndexResourceTest::sortDataProvider in JSON:API Search API 8

Sort data provider.

Return value

\Generator The data.

File

tests/src/Functional/IndexResourceTest.php, line 327

Class

IndexResourceTest
Tests index resource..

Namespace

Drupal\Tests\jsonapi_search_api\Functional

Code

public function sortDataProvider() : \Generator {
  (yield [
    [
      'sort' => 'id',
    ],
    5,
    [
      1,
      2,
      3,
      4,
      5,
    ],
    [],
  ]);
  (yield [
    [
      'sort' => '-id',
    ],
    5,
    [
      5,
      4,
      3,
      2,
      1,
    ],
    [],
  ]);
  (yield [
    [
      'sort' => 'search_api_id',
    ],
    5,
    [
      1,
      2,
      3,
      4,
      5,
    ],
    [],
  ]);
  (yield [
    [
      'sort' => '-search_api_id',
    ],
    5,
    [
      5,
      4,
      3,
      2,
      1,
    ],
    [],
  ]);
  (yield [
    [
      'sort' => [
        'sort-id' => [
          'path' => 'id',
          'direction' => 'ASC',
        ],
      ],
    ],
    5,
    [
      1,
      2,
      3,
      4,
      5,
    ],
    [],
  ]);
  (yield [
    [
      'sort' => [
        'sort-id' => [
          'path' => 'id',
          'direction' => 'DESC',
        ],
      ],
    ],
    5,
    [
      5,
      4,
      3,
      2,
      1,
    ],
    [],
  ]);
}