function FieldItemSerializationTest::testFieldDenormalizeWithScalarValue
Same name in other branches
- 9 core/modules/serialization/tests/src/Kernel/FieldItemSerializationTest.php \Drupal\Tests\serialization\Kernel\FieldItemSerializationTest::testFieldDenormalizeWithScalarValue()
- 8.9.x 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 151
Class
- FieldItemSerializationTest
- Test field level normalization process.
Namespace
Drupal\Tests\serialization\KernelCode
public function testFieldDenormalizeWithScalarValue() : void {
$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');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.