You are here

public function ResourceIdentifierNormalizerTest::testDenormalize in Drupal 8

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

@covers ::denormalize @dataProvider denormalizeProvider

File

core/modules/jsonapi/tests/src/Unit/Normalizer/ResourceIdentifierNormalizerTest.php, line 110

Class

ResourceIdentifierNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\ResourceIdentifierNormalizer @group jsonapi

Namespace

Drupal\Tests\jsonapi\Unit\Normalizer

Code

public function testDenormalize($input, $field_name, $expected) {
  $entity = $this
    ->prophesize(FieldableEntityInterface::class);
  $context = [
    'resource_type' => $this->resourceType,
    'related' => $field_name,
    'target_entity' => $entity
      ->reveal(),
  ];
  $denormalized = $this->normalizer
    ->denormalize($input, NULL, 'api_json', $context);
  $this
    ->assertEquals($expected, $denormalized);
}