public function FieldItemSerializationTest::testFieldDenormalizeWithScalarValue in Drupal 9
Same name and namespace in other branches
- 8 core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php \Drupal\Tests\serialization\Kernel\FieldItemSerializationTest::testFieldDenormalizeWithScalarValue()
- 10 core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php \Drupal\Tests\serialization\Kernel\FieldItemSerializationTest::testFieldDenormalizeWithScalarValue()
Tests denormalizing using a scalar field value.
File
- core/
modules/ serialization/ tests/ src/ Kernel/ FieldItemSerializationTest.php, line 149
Class
- FieldItemSerializationTest
- Test field level normalization process.
Namespace
Drupal\Tests\serialization\KernelCode
public function testFieldDenormalizeWithScalarValue() {
$this
->expectException(UnexpectedValueException::class);
$this
->expectExceptionMessage('Field values for "uuid" must use an array structure');
$normalized = $this->serializer
->normalize($this->entity, 'json');
// Change the UUID value to use the UUID directly. No array structure.
$normalized['uuid'] = $normalized['uuid'][0]['value'];
$this->serializer
->denormalize($normalized, $this->entityClass, 'json');
}