You are here

public function EntityReferenceFieldNormalizerTest::testDenormalize in JSON:API 8

@covers ::denormalize @dataProvider denormalizeProvider

File

tests/src/Unit/Normalizer/EntityReferenceFieldNormalizerTest.php, line 110

Class

EntityReferenceFieldNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\EntityReferenceFieldNormalizer @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
    ->assertSame($expected, $denormalized);
}