protected function FieldItemTest::setUp in Drupal 9
Same name and namespace in other branches
- 8 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 26
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 = mb_strtolower($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
->assertTrue(!empty($definitions[$this->fieldName]));
}