You are here

public function SortTest::testCreateFromQueryParameter in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Unit/Query/SortTest.php \Drupal\Tests\jsonapi\Unit\Query\SortTest::testCreateFromQueryParameter()

@covers ::createFromQueryParameter @dataProvider parameterProvider

File

core/modules/jsonapi/tests/src/Unit/Query/SortTest.php, line 38

Class

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

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']);
  }
}