You are here

public function SortTest::testCreateFromQueryParameter in JSON:API 8.2

@covers ::createFromQueryParameter @dataProvider parameterProvider

File

tests/src/Unit/Query/SortTest.php, line 39

Class

SortTest
@coversDefaultClass \Drupal\jsonapi\Query\Sort @group jsonapi @group legacy

Namespace

Drupal\Tests\jsonapi\Unit\Query

Code

public function testCreateFromQueryParameter($input, $expected) {
  $sort = Sort::createFromQueryParameter($input);
  foreach ($sort
    ->fields() as $index => $sort_field) {
    $this
      ->assertEquals($expected[$index]['path'], $sort_field['path']);
    $this
      ->assertEquals($expected[$index]['direction'], $sort_field['direction']);
    $this
      ->assertEquals($expected[$index]['langcode'], $sort_field['langcode']);
  }
}