function ConfigFieldDefinitionTest::testBundleFieldDefinition

Same name in other branches
  1. 8.9.x core/modules/field/tests/src/Kernel/ConfigFieldDefinitionTest.php \Drupal\Tests\field\Kernel\ConfigFieldDefinitionTest::testBundleFieldDefinition()
  2. 10 core/modules/field/tests/src/Kernel/ConfigFieldDefinitionTest.php \Drupal\Tests\field\Kernel\ConfigFieldDefinitionTest::testBundleFieldDefinition()
  3. 11.x core/modules/field/tests/src/Kernel/ConfigFieldDefinitionTest.php \Drupal\Tests\field\Kernel\ConfigFieldDefinitionTest::testBundleFieldDefinition()

Makes sure a field definition is exposed for a configurable field.

File

core/modules/field/tests/src/Kernel/ConfigFieldDefinitionTest.php, line 45

Class

ConfigFieldDefinitionTest
Tests exposing field definitions for configurable fields.

Namespace

Drupal\Tests\field\Kernel

Code

public function testBundleFieldDefinition() {
    $definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($this->entityType, $this->bundle);
    $this->assertTrue(isset($definitions[$this->fieldTestData->field
        ->getName()]));
    $this->assertInstanceOf(FieldDefinitionInterface::class, $definitions[$this->fieldTestData->field
        ->getName()]);
    // Make sure fields on other entity types are not exposed.
    $this->assertFalse(isset($definitions[$this->fieldTestData->field_rev
        ->getName()]));
}

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