function EntitySerializationTest::testDenormalizeStringValue

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

Tests normalizing/denormalizing using string values.

File

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

Class

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

Namespace

Drupal\Tests\serialization\Kernel

Code

public function testDenormalizeStringValue() {
    $this->expectException(\LogicException::class);
    $this->expectExceptionMessage('The generic FieldItemNormalizer cannot denormalize string values for "value" properties of the "serialized_long" field (field item class: Drupal\\Core\\Field\\Plugin\\Field\\FieldType\\StringLongItem).');
    $this->serializer
        ->denormalize([
        'serialized_long' => [
            'boo',
        ],
        'type' => 'entity_test_serialized_field',
    ], EntitySerializedField::class);
}

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