public function EntitySerializationTest::testDenormalize in Drupal 9
Same name and namespace in other branches
- 8 core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php \Drupal\Tests\serialization\Kernel\EntitySerializationTest::testDenormalize()
- 10 core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php \Drupal\Tests\serialization\Kernel\EntitySerializationTest::testDenormalize()
Tests denormalization of an entity.
File
- core/
modules/ serialization/ tests/ src/ Kernel/ EntitySerializationTest.php, line 268
Class
- EntitySerializationTest
- Tests that entities can be serialized to supported core formats.
Namespace
Drupal\Tests\serialization\KernelCode
public function testDenormalize() {
$normalized = $this->serializer
->normalize($this->entity);
foreach ([
'json',
'xml',
] as $type) {
$denormalized = $this->serializer
->denormalize($normalized, $this->entityClass, $type, [
'entity_type' => 'entity_test_mulrev',
]);
$this
->assertInstanceOf($this->entityClass, $denormalized);
$this
->assertSame($this->entity
->getEntityTypeId(), $denormalized
->getEntityTypeId(), 'Expected entity type found.');
$this
->assertSame($this->entity
->bundle(), $denormalized
->bundle(), 'Expected entity bundle found.');
$this
->assertSame($this->entity
->uuid(), $denormalized
->uuid(), 'Expected entity UUID found.');
}
}