You are here

protected function KernelTestBase::createTestField in JSON Field 8

Creates a field to use in tests.

Parameters

array $field_storage_properties:

array $field_properties:

8 calls to KernelTestBase::createTestField()
JsonFormatterTest::testFormatter in tests/src/Kernel/JsonFormatterTest.php
Tests that the formatter is rendering an empty array.
JsonFormatterTest::testFormatterWithData in tests/src/Kernel/JsonFormatterTest.php
Tests that the formatter is rendering data.
JsonItemTest::testCharacterLimit in tests/src/Kernel/JsonItemTest.php
Test character limit constraints.
JsonItemTest::testFieldCreate in tests/src/Kernel/JsonItemTest.php
Tests that field values are saved a retrievable.
JsonItemTest::testFieldCreateWithDefaultValue in tests/src/Kernel/JsonItemTest.php
Tests that default values are used when no value is added.

... See full list

File

tests/src/Kernel/KernelTestBase.php, line 46

Class

KernelTestBase
Class KernelTestBase.

Namespace

Drupal\Tests\json_field\Kernel

Code

protected function createTestField($field_storage_properties = [], $field_properties = []) {
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'test_json_field',
    'entity_type' => 'entity_test',
    'type' => 'json',
  ] + $field_storage_properties);
  $field_storage
    ->save();
  $field = FieldConfig::create([
    'field_name' => 'test_json_field',
    'entity_type' => 'entity_test',
    'type' => 'json',
    'bundle' => 'entity_test',
  ] + $field_properties);
  $field
    ->save();
}