protected function ContentTranslationTestBase::setupTestFields in Drupal 8
Same name in this branch
- 8 core/modules/content_translation/src/Tests/ContentTranslationTestBase.php \Drupal\content_translation\Tests\ContentTranslationTestBase::setupTestFields()
- 8 core/modules/content_translation/tests/src/Functional/ContentTranslationTestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationTestBase::setupTestFields()
Creates the test fields.
1 call to ContentTranslationTestBase::setupTestFields()
- ContentTranslationTestBase::setUp in core/
modules/ content_translation/ src/ Tests/ ContentTranslationTestBase.php - Sets up a Drupal site for running functional and integration tests.
File
- core/
modules/ content_translation/ src/ Tests/ ContentTranslationTestBase.php, line 185
Class
- ContentTranslationTestBase
- Base class for content translation tests.
Namespace
Drupal\content_translation\TestsCode
protected function setupTestFields() {
if (empty($this->fieldName)) {
$this->fieldName = 'field_test_et_ui_test';
}
FieldStorageConfig::create([
'field_name' => $this->fieldName,
'type' => 'string',
'entity_type' => $this->entityTypeId,
'cardinality' => 1,
])
->save();
FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldName,
'bundle' => $this->bundle,
'label' => 'Test translatable text-field',
])
->save();
\Drupal::service('entity_display.repository')
->getFormDisplay($this->entityTypeId, $this->bundle)
->setComponent($this->fieldName, [
'type' => 'string_textfield',
'weight' => 0,
])
->save();
}