You are here

public function DenormalizeTest::testDenormalizeSerializedItem in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/hal/tests/src/Kernel/DenormalizeTest.php \Drupal\Tests\hal\Kernel\DenormalizeTest::testDenormalizeSerializedItem()

Tests normalizing/denormalizing serialized columns.

File

core/modules/hal/tests/src/Kernel/DenormalizeTest.php, line 146

Class

DenormalizeTest
Tests HAL denormalization edge cases for EntityResource.

Namespace

Drupal\Tests\hal\Kernel

Code

public function testDenormalizeSerializedItem() {
  $entity = EntitySerializedField::create([
    'serialized' => 'boo',
  ]);
  $normalized = $this->serializer
    ->normalize($entity, $this->format);
  $this
    ->expectException(\LogicException::class);
  $this
    ->expectExceptionMessage('The generic FieldItemNormalizer cannot denormalize string values for "value" properties of the "serialized" field (field item class: Drupal\\entity_test\\Plugin\\Field\\FieldType\\SerializedItem).');
  $this->serializer
    ->denormalize($normalized, EntitySerializedField::class, $this->format);
}