You are here

public function FieldStorageCrudTest::testCreateWithExplicitSchema in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php \Drupal\Tests\field\Kernel\FieldStorageCrudTest::testCreateWithExplicitSchema()
  2. 10 core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php \Drupal\Tests\field\Kernel\FieldStorageCrudTest::testCreateWithExplicitSchema()

Tests that an explicit schema can be provided on creation.

This behavior is needed to allow field storage creation within updates, since plugin classes (and thus the field type schema) cannot be accessed.

File

core/modules/field/tests/src/Kernel/FieldStorageCrudTest.php, line 189

Class

FieldStorageCrudTest
Tests field storage create, read, update, and delete.

Namespace

Drupal\Tests\field\Kernel

Code

public function testCreateWithExplicitSchema() {
  $schema = [
    'dummy' => 'foobar',
  ];
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'field_2',
    'entity_type' => 'entity_test',
    'type' => 'test_field',
    'schema' => $schema,
  ]);
  $this
    ->assertEquals($schema, $field_storage
    ->getSchema());
}