function FieldItemTest::setUp
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php \Drupal\KernelTests\Core\Field\FieldItemTest::setUp()
- 8.9.x core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php \Drupal\KernelTests\Core\Field\FieldItemTest::setUp()
- 11.x core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php \Drupal\KernelTests\Core\Field\FieldItemTest::setUp()
Overrides EntityKernelTestBase::setUp
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Field/ FieldItemTest.php, line 28
Class
- FieldItemTest
- Test field item methods.
Namespace
Drupal\KernelTests\Core\FieldCode
protected function setUp() : void {
parent::setUp();
$this->container
->get('state')
->set('entity_test.field_test_item', TRUE);
$this->entityTypeManager
->clearCachedDefinitions();
$entity_type_id = 'entity_test_mulrev';
$this->installEntitySchema($entity_type_id);
$this->fieldName = $this->randomMachineName();
/** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */
FieldStorageConfig::create([
'field_name' => $this->fieldName,
'type' => 'field_test',
'entity_type' => $entity_type_id,
'cardinality' => 1,
])
->save();
FieldConfig::create([
'entity_type' => $entity_type_id,
'field_name' => $this->fieldName,
'bundle' => $entity_type_id,
'label' => 'Test field',
])
->save();
$this->entityTypeManager
->clearCachedDefinitions();
$definitions = \Drupal::service('entity_field.manager')->getFieldStorageDefinitions($entity_type_id);
$this->assertNotEmpty($definitions[$this->fieldName]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.