public function MetatagSerializationTest::testMetatagDeserialization in Metatag 8
Tests the deserialization.
File
- tests/
src/ Kernel/ MetatagSerializationTest.php, line 64
Class
- MetatagSerializationTest
- Tests metatag field serialization.
Namespace
Drupal\Tests\metatag\KernelCode
public function testMetatagDeserialization() {
$entity = EntityTest::create();
$json = json_decode($this->serializer
->serialize($entity, 'json'), TRUE);
$json['field_test'][0]['value'] = 'string data';
$serialized = json_encode($json, TRUE);
$this
->expectException(\LogicException::class);
$this
->expectExceptionMessage('The generic FieldItemNormalizer cannot denormalize string values for "value" properties of the "field_test" field (field item class: Drupal\\metatag\\Plugin\\Field\\FieldType\\MetatagFieldItem).');
$this->serializer
->deserialize($serialized, EntityTest::class, 'json');
}