You are here

public function JsonItemTest::testFieldCreate in JSON Field 8

Tests that field values are saved a retrievable.

File

tests/src/Kernel/JsonItemTest.php, line 20

Class

JsonItemTest
@coversDefaultClass \Drupal\json_field\Plugin\Field\FieldType\JSONItem

Namespace

Drupal\Tests\json_field\Kernel

Code

public function testFieldCreate() {
  $this
    ->createTestField();
  $entity = EntityTest::create([
    'test_json_field' => json_encode([]),
  ]);
  $entity
    ->save();
  $this
    ->assertEquals(json_encode([]), $entity->test_json_field->value);
}