function FieldCrudTest::testReadField
Same name in other branches
- 8.9.x core/modules/field/tests/src/Kernel/FieldCrudTest.php \Drupal\Tests\field\Kernel\FieldCrudTest::testReadField()
- 10 core/modules/field/tests/src/Kernel/FieldCrudTest.php \Drupal\Tests\field\Kernel\FieldCrudTest::testReadField()
- 11.x 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 241
Class
- FieldCrudTest
- Create field entities by attaching fields to entities.
Namespace
Drupal\Tests\field\KernelCode
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.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.