public function FieldCrudTest::testReadField in Drupal 8
Same name and namespace in other branches
- 9 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()
Test 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\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
->assertTrue($this->fieldDefinition['field_name'] == $field
->getName(), 'The field was properly read.');
$this
->assertTrue($this->fieldDefinition['entity_type'] == $field
->getTargetEntityTypeId(), 'The field was properly read.');
$this
->assertTrue($this->fieldDefinition['bundle'] == $field
->getTargetBundle(), 'The field was properly read.');
}