function FieldStorageCrudTest::testCreateWithExplicitSchema

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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());
}

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