You are here

public function FieldCrudTest::testReadField in Drupal 10

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

Tests reading back a field definition.

File

core/modules/field/tests/src/Kernel/FieldCrudTest.php, line 238

Class

FieldCrudTest
Create field entities by attaching fields to entities.

Namespace

Drupal\Tests\field\Kernel

Code

public function testReadField() {
  FieldConfig::create($this->fieldDefinition)
    ->save();

  // Read the field back.
  $field = FieldConfig::load('entity_test.' . $this->fieldDefinition['bundle'] . '.' . $this->fieldDefinition['field_name']);
  $this
    ->assertSame($this->fieldDefinition['field_name'], $field
    ->getName(), 'The field was properly read.');
  $this
    ->assertSame($this->fieldDefinition['entity_type'], $field
    ->getTargetEntityTypeId(), 'The field was properly read.');
  $this
    ->assertSame($this->fieldDefinition['bundle'], $field
    ->getTargetBundle(), 'The field was properly read.');
}