function EntitySerializationTest::testDenormalizeEmptyCustomSerializedField

Same name in other branches
  1. 9 core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php \Drupal\Tests\serialization\Kernel\EntitySerializationTest::testDenormalizeEmptyCustomSerializedField()
  2. 8.9.x core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php \Drupal\Tests\serialization\Kernel\EntitySerializationTest::testDenormalizeEmptyCustomSerializedField()
  3. 10 core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php \Drupal\Tests\serialization\Kernel\EntitySerializationTest::testDenormalizeEmptyCustomSerializedField()

Tests normalizing/denormalizing empty custom serialized fields.

File

core/modules/serialization/tests/src/Kernel/EntitySerializationTest.php, line 338

Class

EntitySerializationTest
Tests that entities can be serialized to supported core formats.

Namespace

Drupal\Tests\serialization\Kernel

Code

public function testDenormalizeEmptyCustomSerializedField() : void {
    $entity = EntitySerializedField::create([
        'serialized_long' => serialize([]),
    ]);
    $normalized = $this->serializer
        ->normalize($entity);
    $this->assertEquals([], $normalized['serialized_long'][0]['value']);
    $entity = $this->serializer
        ->denormalize($normalized, EntitySerializedField::class);
    $this->assertEquals(serialize([]), $entity->get('serialized_long')->value);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.