You are here

public function SortNormalizerTest::testDenormalize in JSON:API 8

@covers ::denormalize @dataProvider denormalizeProvider

File

tests/src/Kernel/Normalizer/SortNormalizerTest.php, line 49

Class

SortNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\SortNormalizer @group jsonapi @group jsonapi_normalizers @group legacy

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

public function testDenormalize($input, $expected) {
  $sort = $this->normalizer
    ->denormalize($input, Sort::class, NULL, [
    'entity_type_id' => 'foo',
    'bundle' => 'bar',
  ]);
  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']);
  }
}