You are here

function FieldCrudTest::testReadField in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Tests/FieldCrudTest.php \Drupal\field\Tests\FieldCrudTest::testReadField()

Test reading back a field definition.

File

core/modules/field/src/Tests/FieldCrudTest.php, line 182
Contains \Drupal\field\Tests\FieldCrudTest.

Class

FieldCrudTest
Create field entities by attaching fields to entities.

Namespace

Drupal\field\Tests

Code

function testReadField() {
  entity_create('field_config', $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.');
}